Sayyiduna Abu Hurairah (may Allah be pleased with him) said: The Messenger of Allah (peace and blessings be upon him) said: "Mounts should not be saddled (i.e., journeys should not be undertaken) except to three mosques: Al-Masjid Al-Haram (the Sacred Mosque in Makkah), this mosque of mine (the Prophet's Mosque in Madinah), and Al-Masjid Al-Aqsa (i.e., Bayt Al-Maqdis in Jerusalem)."
Hadith Referenceسنن دارمي / من كتاب الصللاة / 1459
Hadith Takhrijاس روایت کی سند صحیح اور حدیث متفق علیہ ہے۔ دیکھئے: [بخاري 1189] ، [مسلم 1397] ، [أبوداؤد 2033] ، [نسائي 699] ، [ابن ماجه 1409] ، [أبويعلی 5880] ، [ابن حبان 1619] ، [الحميدي 973]
Brief Explanation
(Commentary on Hadith 1458)
It is established from this hadith that, except for these three mosques, it is not permissible to travel to any other mosque with the intention of earning reward, and to travel with the intention of reward to graves and shrines is in fact forbidden (haram). Even the scholars have considered traveling to Madinah Munawwarah with the intention of visiting the blessed tomb (rawdah) of the Noble Prophet sallallahu alayhi wa sallam as contrary to the Shari‘ah and in opposition to the aforementioned hadith. However, if a person goes to Masjid al-Nabawi and also visits the tomb of the Noble Prophet sallallahu alayhi wa sallam, then there is no harm in this. Upon reaching there, sending salutations (salat and salam) in the prescribed Shari‘ah manner and conveying greetings to Sayyiduna Abu Bakr and Sayyiduna Umar radi Allahu anhuma and other Companions is not blameworthy. Similarly, going to the nearby graveyards for the sake of reflection and admonition, and making supplication (dua) for the deceased, is also not contrary to the Shari‘ah; rather, it is permissible and recommended (mustahabb). The prohibition is only regarding “shadd al-rihal” (i.e., undertaking a journey specifically) to visit a particular grave, shrine, tomb, or graveyard for the purpose of attaining reward, or to seek intercession from the occupant of the grave, or to seek livelihood or fulfillment of needs by traveling there—this is contrary to the Shari‘ah and forbidden (haram).
May Allah grant everyone understanding of the religion.