All of the aḥādīth about visiting his grave are daʿīf, and are not to be relied upon in matters of religion. For this reason none of the authors of books of Ṣaḥīḥ and Sunan reported them at all.
Al-Daaraqutni reported in his Sunan (2/278) with an isnād from Haatib that the Messenger of Allāh (peace and blessings of Allāh be upon him) said: “Whoever visits me after I die, it is as if he visited me when I was still alive…” This is a ḥadīth that many of the scholars of ḥadīth judged to be false and not to have been reported with a ṣaḥīḥ isnād from the Prophet (peace and blessings of Allāh be upon him). Among the scholars who voiced this opinion was al-Ḥāfiẓ al-Dhahabi in Lisān al-Mīzān (4/285), in his biography of one of the narrators, Hārūn ibn Abī Qaz’ah. Al-Dhahabi said: “…Hārūn ibn Abī Qaz’ah al-Madani [reported] from a man” – about visiting the grave of the Prophet (peace and blessings of Allāh be upon him). Al-Bukhārī said: “This is not to be accepted or followed.”
Al-Ḥāfiẓ Ibn Ḥajar said in Lisān al-Mīzān (6/217): “Al-Azdi said: ‘Hārūn Abū Qaz’ah reports mursal aḥādīth from a man of Āl Haatib.’ I [Ibn Ḥajar] say: from this, we understand that what he is referring to is al-Azdi. Ya’qoob ibn Shaybah also classed him as ḍaʿīf (weak).”
Al-Ḥāfiẓ ibn Ḥajar also mentioned him in al-Talkhees al-Habeer, in his comment on the aḥādīth of al-Rāfa’i al-Kabīr (2/266). He said, “In his isnād is the unknown [majhūl] man” – meaning a man from Āl Haatib.
Shaykh al-Islām Ibn Taymīyyah said in al-Tawassul wa’l-Waseelah (p. 134) about this ḥadīth: “It is obviously a lie that goes against Islām. Anyone who visited him during his lifetime and believed in him, was one of his Companions, especially if he was among those who migrated to join him or fought alongside him. It is proven that he (peace and blessings of Allāh be upon him) said: ‘Do not slander my Companions, for by the One in Whose hand is my soul, if any one of you were to spend gold equal to the size of Uhud, it would not equal the deeds of one of them, not even half of it.’ [Reported by al-Bukhārī and Muslim]. Anyone who comes after the Ṣaḥābah cannot be like the Ṣaḥābah by doing obligatory duties such as Ḥajj, jihād, the five daily prayers and sending blessings upon the Prophet (peace and blessings of Allāh be upon him), so how can he become equal to them by doing something that is not obligatory according to the consensus of the Muslims? We are not even supposed to travel for this purpose; in fact, it is forbidden to do so. However, travelling to the [Prophet’s] Mosque, and to al-Masjid al-Aqsaa [in Jerusalem], for the purpose of praying there, is mustahabb (encouraged), and travelling to the Kaʿbah for Ḥajj is wājib (obligatory). If a person who undertakes a journey that is wājib or mustahabb still cannot be like one of the Ṣaḥābah who traveled to visit the Prophet (peace and blessings of Allāh be upon him) during his lifetime, how can they achieve this by undertaking a journey that is not allowed?”
He also said (p. 133): “All of the aḥādīth about visiting his grave are ḍaʿīf, and are not to be relied upon in matters of religion. For this reason, none of the authors of books of Ṣaḥīḥ and Sunan reported them at all; they were only narrated by those who reported ḍaʿīf aḥādīth, such as al-Daaraqutni, al-Bazzār and others.
Shaykh al-Albānī said in al-Da’eefah (no. 1021) about this ḥadīth: it is bāṭil (false). He mentioned what is wrong with the ḥadīth, namely the man who is not named and classed Hārūn Abū Qaz’ah as ḍaʿīf. There is a third fault with the ḥadīth, which is that it causes confusion and contraḍīction. Then Shaykh al-Albānī said: “In general, the isnād of this ḥadīth is weak.”
He also said in al-Da’eefah (no. 47): “many people think that Shaykh al-Islām Ibn Taymīyah and those who follow him among the Salafīs forbid visiting the grave of the Prophet (peace and blessings of Allāh be upon him) altogether. This is a lie and a fabrication, and it is not the only lie told about Ibn Taymīyah, may Allāh have mercy on him, or about the Salafīs. Everyone who reads the books of Ibn Taymīyah will see that he says it is permissible to visit his grave (peace and blessings of Allāh be upon him), and that doing so is recommended (mustahabb), so long as it is not associated with any objectionable practices or innovations (bidʿah), such as travelling solely for that purpose, because of the ḥadīth “No one should set out purposely except to visit three mosques.” The ḥadīth does not describe a ban only on travelling to visit other mosques, as many people think; it also includes a ban on setting out to visit any place which people think will bring them closer to Allāh, whether it is a mosque, a grave or any other place. This is indicated by the ḥadīth narrated by Abū Hurayrah who said: ‘I met Baṣrah ibn Abī Baṣrah al-Ghifāri and he asked me, ‘Where are you coming from?’ I said, ‘From al-Toor [Sinai].’ He said, ‘If I had met you before you left, you would not have gone there! I heard the Messenger of Allāh (peace and blessings of Allāh be upon him) say: ‘Do not travel except to three mosques.'” (Reported by Aḥmad and others with a ṣaḥīḥ isnād).
This clearly indicates that the Ṣaḥābah understood the ḥadīth to be general in application [i.e., it did not apply only to mosques]. This is supported by the fact that it is not reported that any of them ever set out with the intention of visiting a grave. They are the predecessors of Ibn Taymīyah in this regard, so whoever condemns Ibn Taymīyah is in effect condemning the salaf (the righteous predecessors), may Allāh be pleased with them. May Allāh have mercy on the one who said:
“All goodness is in following those who went before (the salaf) and all evil is in following the innovations of those who came later.”
In conclusion, travelling with the intention of visiting the grave of the Prophet (peace and blessings of Allāh be upon him) is bidʿah and is ḥarām, because of the ḥadīth which forbids travelling to worship in any place except the three mosques. As for visiting the grave of the Prophet (peace and blessings of Allāh be upon him) when one happens to be in Madīnah, this is perfectly acceptable, as is travelling with the intention of praying in the Prophet’s Mosque as an act of worship and seeking to draw close to Allāh. Those that are confused about this issue are those who do not understand the difference between what is permitted and what is forbidden. And Allāh knows best.