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.
The ruling on visiting only the blessed grave:
However, the person who travels only to visit the honored grave (like grave worshippers) and neither prays in the Prophet's Mosque nor sends blessings and salutations upon the pure person of the Messenger of Allah, but merely comes to the honored grave and then leaves, such a person is an innovator and misguided, opposing the Sunnah of the Messenger, the consensus of the Companions, and the scholars of the Ummah. There are two opinions regarding such a person:
1: One is that he has committed a forbidden act.
2: The second opinion is that such a person neither receives punishment nor reward.
As for the Shariah visitation, which the scholars of the Ummah practice, it is that prayer is performed in the Prophet's Mosque, and during the prayer, and upon entering and leaving the mosque, blessings and salutations are sent upon the Messenger of Allah. This practice is unanimously considered Sunnah by all Muslims.
We have mentioned this discussion in the rituals and our fatwas, stating that when a person comes near the honored grave, he should send salutations upon the Prophet Muhammad (peace be upon him) and his two companions Abu Bakr and Umar (may Allah be pleased with them). However, I did not mention the disagreement in my fatwas, although there is scholarly disagreement on this matter.
Some scholars say that visiting graves is not recommended at all, while others say it is absolutely disliked. Among those who consider it disliked are Ibrahim Nakha'i, Shu'bi, and Muhammad bin Sirin (may Allah have mercy on them), whose names are worthy of mention. They are counted among the foremost Tabi‘in. It is also narrated from Imam Malik (may Allah have mercy on him) that he held this view. But he also had an opinion that visiting graves is permissible but not recommended. Imam Ahmad (may Allah have mercy on him) also has a statement supporting this. However, the apparent view of him and the majority of scholars is that the Shariah visitation is recommended. The Shariah visitation is to visit the cemetery of the believers for the purpose of supplication, to pray for them, and to send salutations upon them. It is also recommended to visit the graves of disbelievers because it refreshes the remembrance of the Hereafter.
As for the Noble Messenger (peace be upon him), he has such superiority over all creation that has no parallel, and that is that the purpose of visiting an ordinary grave is to pray for the occupant of the grave. But for the Messenger of Allah, the ruling is that blessings and salutations are sent upon him five times during prayer, upon entering and leaving the mosque, at the end of the call to prayer, and also during supplication. The Noble Messenger forbade making graves places of worship. Especially, he strictly prohibited turning his grave into a place of festivity. He also prayed to Allah, saying, "O Allah! Do not let my grave become an idol." Therefore, everyone is prohibited from going near the honored grave, although visiting ordinary graves is permitted.
The abundance of blessings and salutations sent upon the Messenger of Allah (peace be upon him) in the Prophet's Mosque and other mosques is a special virtue that no other prophet has. The permissible acts performed at ordinary graves have been made unnecessary for the honored grave. As for making graves places of prostration, the ruling is that graves should not be made places of prostration, even if the worshipper prays to Allah alone and calls upon Him. Therefore, people are not permitted to go to graves to prostrate, to call upon the creation instead of the Creator, to offer prayers in the name of the dead, or to perform acts that polytheists, innovators, and misguided sects perform.
Whoever comes to the Prophet's Mosque but does not pray and instead goes directly to the honored grave and leaves without praying, this is an act that Imam Malik (may Allah have mercy on him) and other Imams of Islam have considered blameworthy, and there is not a single scholar of the Ummah who has deemed this act recommended. However, there is disagreement among scholars whether this act is forbidden or permissible.
Not a single scholar of the Ummah has called this act recommended; rather, they have considered such a journey blameworthy if its sole purpose is to visit the honored grave without intending to pray in the Prophet's Mosque. According to their opinion, this journey is one that the Noble Messenger (peace be upon him) forbade. Indeed, among the Salaf of the Ummah, there is not a single person who undertook such a journey. Rather, when the Companions traveled to Madinah Munawwarah for visitation, they prayed in the Prophet's Mosque, sent blessings and salutations upon the Messenger of Allah upon entering and leaving the mosque, and then visited the caliph of the time to discuss important matters. But they did not attempt to go near the honored grave. This practice of the Companions has reached the level of mutawatir (mass transmission). No one can prove that any one Companion prayed behind any of the Rightly Guided Caliphs and then immediately or after a short while went to the blessed chamber. The question of entering the blessed chamber does not even arise.
The method of all the Companions was that if they traveled to the Prophet's Mosque, upon arrival they performed the acts that the Messenger of Allah had taught and explained to them, and they never went near the honored grave. Can it be imagined that such pure souls ever traveled with the sole intention of visiting the honored grave? Now, whoever considers such a journey recommended should present the opinion of any of the great Imams as evidence. And if, by some rare chance, it is narrated from any Imam, his opinion will be considered contrary to the Sunnah of the Prophet, the consensus of the Companions, and the scholars of the Ummah. Allah Almighty says about such a person:
وَمَن يُشَاقِقِ الرَّسُولَ مِن بَعْدِ مَا تَبَيَّنَ لَهُ الْهُدَىٰ وَيَتَّبِعْ غَيْرَ سَبِيلِ الْمُؤْمِنِينَ نُوَلِّهِ مَا تَوَلَّىٰ وَنُصْلِهِ جَهَنَّمَ ۖ وَسَاءَتْ مَصِيرًا ﴿١١٥﴾
"And whoever opposes the Messenger after guidance has been made clear to him and follows a path other than that of the believers - We will keep him in the path he has chosen, and burn him in Hell - what an evil destination."
Reference: (4-An-Nisa:115)
❀ And the Messenger of Allah said:
إنما الأعمال بالنيات وإنما لكل امرئ ما نوىٰ
"Actions are judged by intentions, and every person will get what he intended."
Reference: (Sahih al-Bukhari, Book of the Beginning of Revelation: Chapter How the Revelation Began to the Messenger of Allah (Hadith: 1); Sahih Muslim, Book of Faith: Chapter The Prophet (peace be upon him) said: 'Actions are but by intentions' (Hadith 1907))[ /ref]