This excerpt is taken from Sheikh al-Islam Imam Ibn Taymiyyah's book Al-Jawab al-Bahir fi Zuwar al-Maqabir, translated by Sheikh Ataullah Saqib.
Limitations of the Journey for Visitation:
Masjid al-Nabawi, Masjid al-Haram, and Masjid al-Aqsa are the three mosques for whose visitation (especially with a specific intention) traveling is Sunnah; traveling for the visitation of any other mosque is prohibited.
It is always necessary to keep in mind the important difference between the lawful and unlawful visitation of graves. For example, making the graves of Prophets and righteous people places of prostration, or praying facing the grave, or making any grave an object of worship and dedicating it specifically for worship, is forbidden. In Sahihain, there is a Prophetic narration that states:
لا تشد الرحال إلا إلى ثلاثة مساجد المسجد الحرام ومسجدي هذا والمسجد الأقصى
"Do not set out on a journey to visit any mosque except these three mosques (i.e., Masjid al-Haram, Masjid al-Nabawi, and Masjid al-Aqsa)."
Reference: (Sahih Bukhari, Book of the Virtue of Prayer in Mecca and Medina: Chapter on the Virtue of Prayer in Mecca and Medina, Hadith: 1189; Sahih Muslim - Book of Hajj: Chapter on the Virtue of the Three Mosques, Hadith: 1397)
Once it is narrated that Sayyiduna Abu Hurairah (may Allah be pleased with him) went to the mountain where Sayyiduna Musa bin Imran (peace be upon him) used to speak with Allah. On his return, he met Basrah bin Abu Basrah al-Ghifari (may Allah be pleased with him), who said: "If I had known earlier, you would never have been able to go there, because I heard the Messenger of Allah (peace and blessings be upon him) say:
لا تعمل المطي إلا إلى ثلاثة مساجد المسجد الحرام ومسجدي هذا ومسجد بيت المقدس
"Do not ride a mount to any mosque except three mosques, namely (1) Masjid al-Haram, (2) my mosque (i.e., Masjid al-Nabawi), and (3) Masjid Bayt al-Maqdis (al-Aqsa Mosque)."
Reference: (Sunan an-Nasa'i, Book of Friday: Chapter on the Time When Supplication is Answered on Friday, Hadith: 1431)
These three mosques are such that traveling specifically for worship and visitation to them is Sunnah, such as praying, reciting the Quran, engaging in dhikr and supplications, and performing i'tikaf. Among these three mosques, only the circumambulation (tawaf) of Masjid al-Haram is Sunnah. Whoever prays in any mosque other than these three (without having traveled specifically for visitation to that mosque) then, according to authentic hadiths, this act will be considered the best of all deeds. For example, in Sahihain, the Messenger of Allah (peace and blessings be upon him) said:
من تطهر فى بيته ثم خرج إلى المسجد كانت خطواته إحداها تحط خطيئة والأخرى ترفع درجة والعبد فى صلاة ما دام ينتظر الصلاة والملائكة تصلي على أحدكم ما دام فى مصلاه الذى صلى فيه تقول اللهم اغفر له اللهم ارحمه ما لم يحدث
"Whoever purifies himself at home and then goes to the mosque, every step he takes removes a sin and raises him a degree, and as long as he waits for the prayer, he continues to receive the reward of prayer. And as long as he sits in the mosque, the angels pray for him, 'O Allah, forgive him, have mercy on him,' until he performs ablution again."
Reference: (Sahih Muslim, Book of Mosques: Chapter on Walking to Prayer Erases Sins and Raises Degrees, Hadith: 666; see also the following hadith)
Reference: Sahih Bukhari, Book of Adhan: Chapter on the Virtue of Congregational Prayer, Hadith: 647; Sahih Muslim, Book of Mosques: Chapter on the Virtue of Obligatory Prayer in Congregation, Hadith: 649)
However, if a person travels from one city to another with the intention that there is a mosque there, such as traveling from Damascus to Egypt or from a distant city to visit Masjid Quba, such travel is unanimously considered impermissible by the four Imams. If someone makes a vow to undertake such travel, fulfilling it is not obligatory according to the consensus of the four Imams. Only a weak statement from Laith bin Saad exists that such a vow should be fulfilled. Among Imam Malik's companions, only Ibn Muslimah considered it necessary to fulfill a vow to travel to Masjid Quba. However, if a person goes to Madinah Munawwarah, it is recommended for him to pray in Masjid Quba because traveling from Madinah to Masjid Quba is not considered travel. This is because the practice of the Messenger of Allah (peace and blessings be upon him) was to go to Masjid Quba on Saturdays, sometimes on foot and sometimes riding, and to pray two rak'ahs there.
Reference: (Sahih Bukhari, Book of the Virtue of Prayer in Mecca and Medina, Chapter on Coming to Masjid Quba Walking or Riding, Hadith: 1193; Sahih Muslim, Book of Hajj, Chapter on the Virtue of Masjid Quba and Prayer Therein, Hadith: 1399)
In this regard, the Prophet (peace and blessings be upon him) also said:
من تطهر فى بيته ثم أتى مسجد قباء فصلى فيه صلاة كان له كأجر عمرة
"Whoever purifies himself at home and goes to Masjid Quba and prays there, it is as if he has performed Umrah."
Reference: (Sunan an-Nasa'i, Book of Mosques, Chapter on the Virtue of Masjid Quba and Prayer Therein, Hadith: 703; Sunan Ibn Majah, Book of Establishing Prayer and Sunnah in It, Chapter on What Has Been Reported About Prayer in Masjid Quba, Hadith: 1412)
Similarly, Sa'd bin Abi Waqqas (may Allah be pleased with him) and Abdullah bin Umar (may Allah be pleased with them) used to say:
"Praying in Masjid Quba has the reward equivalent to performing Umrah."
Reference: (Musannaf Ibn Abi Shaybah: 3/373)
If a person makes a vow to perform Hajj or Umrah, all scholars of the Ummah agree that he must fulfill this vow. If a person makes a vow to go to Masjid al-Nabawi or Masjid al-Aqsa, scholars have two opinions regarding such a vow:
1. According to Imam Abu Hanifa (may Allah have mercy on him) and one opinion of Imam Shafi'i (may Allah have mercy on him), fulfilling such a vow is not obligatory because the Shariah has not made it obligatory.
2. According to Imam Malik (may Allah have mercy on him), Imam Ahmad bin Hanbal (may Allah have mercy on him), and another opinion of Imam Shafi'i (may Allah have mercy on him), fulfilling such a vow is obligatory because it is obedience to Allah. Regarding obedience to Allah, the Prophet (peace and blessings be upon him) said in Sahih Bukhari:
من نذر أن يطيع الله فليطعه ومن نذر أن يعصي الله فلا يعصه
"Whoever makes a vow to obey Allah, he must obey Allah, and whoever makes a vow to disobey Allah, he must not disobey Allah."
Reference: (Sahih Bukhari, Book of Oaths and Vows, Chapter on Vows in Obedience, Hadith: 6696, 6700)
If someone makes a vow to travel to any mosque other than these three, or merely vows to visit the honored grave of the Messenger of Allah (peace and blessings be upon him) or any other Prophet, Wali, or righteous person, then according to the consensus of the Imams, fulfilling such a vow is not obligatory because the Messenger of Allah (peace and blessings be upon him) did not command such travel. Rather, he said:
لا تشد الرحال إلا إلى ثلاثة مساجد المسجد الحرام ومسجدي هذا والمسجد الأقصى
"Do not set out on a journey to visit any mosque except these three mosques, namely Masjid al-Haram, my mosque, and Masjid al-Aqsa."
Reference: (Sahih Bukhari, Book of the Virtue of Prayer in Mecca and Medina, Chapter on the Virtue of Prayer in Mecca and Medina, Hadith: 1189; Sahih Muslim, Book of Hajj, Chapter on the Virtue of the Three Mosques, Hadith: 1397)
Yes! Fulfilling a vow that involves obedience to the Messenger (peace and blessings be upon him) is obligatory. Imam Malik (may Allah have mercy on him) and many other Imams have clarified that if a person vows to travel to Madinah Munawwarah with the intention of praying in Masjid al-Nabawi, he must fulfill his vow. But if his intention is only to visit the honored grave (without praying in the mosque), then fulfilling the vow is not obligatory because the Messenger of Allah (peace and blessings be upon him) said:
لا تعمل المطي إلا إلى ثلاثة مساجد
"Do not ride a mount except to three mosques."
Reference: (Sunan an-Nasa'i, Book of Friday, Chapter on the Time When Supplication is Answered on Friday, Hadith: 1431)
This issue is also supported by the books Al-Mudawwana and Al-Jallab, etc.
Reference: Al-Mudawwana and Al-Jallab are famous books of Maliki fiqh. (Translator)
Qadi Ismail bin Ishaq, while discussing this, quotes Imam Malik's statement: "Whoever vows to go to Masjid al-Nabawi must fulfill his vow because the purpose of going to the mosque is to pray. Whoever vows to go to Madinah Munawwarah with the intention of praying in Masjid al-Nabawi must fulfill his vow. But if the intention is to visit Jannat al-Baqi or the graves of the martyrs of Uhud, then fulfilling the vow is not obligatory because traveling to any mosque other than the three mentioned is not permissible."
No Imam among the scholars of Islam has opposed Imam Malik's above statement; rather, the writings of other Imams support him. Regarding traveling for the visitation of graveyards, two opinions are reported from Imam Shafi'i (may Allah have mercy on him) and his companions: that such travel is either forbidden or permissible.
The earlier companions of Imam Shafi'i and Imam Ahmad (may Allah have mercy on them) said this travel is forbidden, but among the later companions, a difference of opinion arose. The difference was due to the hadith ”لا تشد الرحال“, which is in the form of a prohibition, indicating that such travel is forbidden.
Some said that the hadith uses a negative form which means that this travel is neither Sunnah, nor obligatory, nor recommended, but permissible. This travel would be like traveling to a city for trade.
In response, we say that traveling for trade is not for worship but for worldly purposes, which are permissible, unlike visiting graves, whose purpose is worship, and worship can only be performed through obligatory or recommended acts.
When it is unanimously established that traveling for the visitation of graves is neither obligatory nor recommended, then whoever travels for visitation as an act of worship will be considered an innovator and against consensus because introducing new acts in worship is not permissible. However, one who is unaware will be excused, but once the Sunnah method is known, he should not oppose the Sunnah nor do anything that the Prophet (peace and blessings be upon him) forbade, such as praying at sunrise or sunset or fasting on the two Eids, even though prayer and fasting are among the best deeds. If done before knowledge, he will not be sinful.
All schools of thought among Muslims agree that traveling for the visitation of graves is not recommended. Also, none of the Imams of Islam have reported that traveling to a graveyard is recommended. If any follower of the Imams has said so, it is not impossible, but none of the Mujtahid Imams have called it recommended. Even if, hypothetically, it is reported from any Imam, it would be considered a third opinion, but remember that this opinion would be against the Sunnah and the consensus of the Companions.