The ruling on visiting the Prophetic Mosque and traveling for that purpose
Question :
A person wants to visit the Prophetic Mosque in Al- Madinah Al-Munawwarah and he is in Makkah. Thus, he asks is that permissible?
Answer:
It is permissible for the Muslim to travel to Al-Madinah to pray in the Prophetic Mosque. Actually, it is recom- mended, because the prayer in it is worth 1,000 prayers in any other place except the Sacred Mosque (Al-Masjid Al-Haram in Makkah). If he is in Makkah, his prayer in the Sacred Mosque is better than his traveling to pray in the Prophetic Mosque. This is because the prayer in the Sacred Mosque is worth 100,000 prayers in any other place (besides the Prophet's Mosque in Al- Madinah). It is not permissible for him to travel to Al-Madinah in order to visit the Prophet's grave or other graves. This is due to what is confirmed from the Prophet ﷺ that he said:
"Do not undertake a (religious) journey except to three Mosques: The Sacred Mosque (in Makkah), this mosque of mine (in Al- Madinah), and Al-Masjid Al-Aqsa (in Jerusalem)."
This Hadith was recorded by Imam Ahmad, Al-Bukhari, Muslim, Abu Dawud, An-Nasa'i and Ibn Majah. May blessings and peace be upon our Prophet Muhammad ﷺ, his family and his Companions.
Source:
The Permanent Committee
Fatawa Islamiyah, Vol. 4 Page 310