As for the former group, they cite as evidence the Prophet’s saying, peace and blessings be upon him, recorded in the two Sahīh collections:
“No journey should be undertaken except to three mosques: the Sacred Mosque, this mosque of mine, and al-Aqsā Mosque.”
The imams agree that this hadith is authentic and is to be acted upon. If a man vows to undertake a journey to pray or observe a devotional retreat at a mosque or shrine other than these three mosques, or to travel there, he is not obliged to fulfil that vow, by agreement of the imams. If he vows to travel to the Sacred Mosque for Hajj or ‘umrah, he is obliged to do so, by agreement of the scholars.
If he vows to visit the Prophet’s Mosque, peace and blessings be upon him, or al-Aqsā Mosque for prayer or a devotional retreat, he must fulfil this vow according to Mālik, al-Shāfi‘ī in one of his two opinions, and Ahmad. According to Abū Hanīfah, however, he is not obliged to do so, because in his view a vow becomes binding only when the act belongs to a category already made obligatory by Islamic law.
The majority, however, hold that a vow to perform any act of obedience must be fulfilled, as established in Sahīh al-Bukhārī, on the authority of ‘Ā’ishah, may Allah be pleased with her, that the Prophet, peace and blessings be upon him, said:
“Whoever vows to obey Allah, let him obey Him; and whoever vows to disobey Allah, let him not disobey Him.”
Travelling to these two mosques is an act of obedience; therefore, a vow to do so must be fulfilled.