Hazrat Abu Huraira R.A. reports that Rasulullah Sal’am said: “It is not permissible that a journey should be undertaken towards any mosque except one of the following three: the Masjid-ul-Haraam, Masjid-ul-Aqsaa and this Masjid of mine.” (Mishkaat)
In this hadith one is prohibited from undertaking a journey for visiting any mosque any of the three. For this reason some ulama stated that one is not allowed undertaking a journey to visit the grave of Rasulullah Sal’am. They even go so far as to state that one should visit Madina only with the intention of visiting the mosque, not the grave. If after visiting the mosque, they do visit the grave of the Nabi Sal’am, it is not prohibited. According to the vast majority of ulama, that is not the meaning of this Hadith. This Hadith in fact means that apart from the three mosques, a journey may not be undertaken to visit any other mosque because whereas mosques are of great importance and significance, other mosques do not have any special significance. (see hadith No. 6 in chapter 4). The view of these learned scholars is substantiated by this same Hadith as reported in some versions thereof that to no other mosques other than these three may one undertake a journey.
Hence it is prohibited to visit a certain town specifically in order to visit the mosque as is the custom these days when from all over e.g. Bombay, Calcutta etc. people come to Delhi to perform the last Jum’aa of Ramdhaan in the Delhi Jum’aa Masjid. This is a mere waste of money. Hazrat Imaam Ghazaali Rah says: “Some ulama, had prohibited the Ziyaarat of the graves of sahaaba and ulama because of this hadith, even though the Rasool Sal’am is reported to have said: “Previously I prohibited you from visiting the graves. Now I permit you to do so. Visit then graves.” The hadith under discussion points out that all mosques (apart from the three mentioned) are equal in virtue. Not one of them have anything special lifting it above the rest, and thus giving rise to their being specially visited. As for the graves of the holy ones and blessings derived there this is a matter apart from that. I now ask: ‘is it then also prohibited to visit the graves of the Prophets? No. And as the visiting of the graves of the Prophets cannot be prohibited, so also visiting of the graves of the saints too cannot be prohibited.
Now, there is another point. The ulama are not agreed as to whether it is permissible to undertake a journey to the graves of saints. However, there is no doubt that apart from travelling to these mosques, many other journeys too are permissible and in fact compulsory e.g. traveling for Jihaad, traveling in search of knowledge, traveling on Hijrat, business journeys etc. Hence everyone must come to the conclusion that the Hadith does not set out to prohibit all journeys except towards three masjids.
Hazrat Allama Qastalaani Rah tells the following story: Hazrat ‘Shaikh Waliyud-deen Iraaqui Rah says: “My father Hazrat Zain Iraaqi and Shaikh Abdur Rahman bin Rajab Hanbali Rah once went on a journey to visit the grave of Hazrat Nabi Ibrahim A.S., when they approached the city, Ibn Rajab thought within himself and said: “I have made the niyyat to perform two rak’aats salaat in the masjid of Khalil (hazrat Ibrahim A.S) so that the niyyat may not be that I came solely to visit the grave.” Zain Iraaqi replied: “In that case you have definitely acted not in accordance with the saying of Rasulullah Sal’am, because he said one should not travel in order to visit a masjid other than one of the three masjids and now you have made the intention to visit a fourth. As for myself, I have done as he commanded for he said: “visit the graves and no where did he say one should only visit the graves of Prophets. Hence I have done as the Nabi Sal’am wishes”. (Zurqaani)