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.
Special Salat and Salam for the Noble Prophet Muhammad ﷺ
Greeting the Prophet Muhammad ﷺ with peace upon entering and leaving the mosque during prayer is your special practice. This is an act commanded in the Holy Quran, and whoever sends blessings and peace upon the Prophet Muhammad ﷺ, Allah sends mercy upon him ten times. This is an act that is superior, beneficial, and complete, and there is no fear of fitnah or corruption in it. Sending blessings and peace is not an act specific to the honored grave, nor is traveling permitted for this act. Rather, intending this purpose would be equivalent to turning the honored grave into a fair. As the Prophet Muhammad ﷺ said:
"Do not turn my house into a fair."
Reference: (Sunan Abi Dawood, Book of Pilgrimage: Chapter on Visiting Graves, Hadith: 2042)
Therefore, during the time of the Companions, the Rightly Guided Caliphs, and the early Muhajirun and Ansar, it was customary for them to visit the Prophet's Mosque. According to the commands of Allah and the Prophet Muhammad ﷺ, they would send blessings and peace upon him. And during prayer, they would supplicate for themselves with whatever prayers they preferred most. For example, when Ibn Mas'ud (may Allah be pleased with him) was taught the Tashahhud in the Sahihayn, he said that after the Tashahhud, pray whatever you wish.
Reference: (Sahih Bukhari, Book of Adhan: Chapter on Choosing Supplications after Tashahhud, Hadith: 835; Sahih Muslim, Book of Prayer: Chapter on Tashahhud in Prayer, Hadith: 402)
The Conduct of the Companions of the Prophet
The noble Companions, may Allah be pleased with them, did not go near the blessed chamber or inside it near the honored grave to offer salutations or any other prescribed acts, as the polytheists and innovators do. Such polytheistic practices did not exist in the first three centuries. The eras of the Companions, the Followers (Tabi‘in), and the Followers of the Followers (Taba‘ al-Tabi‘in) were completely free, clean, and refined from these innovations.
If a knowledgeable and faithful person reflects on the aforementioned evidences, the true religion and correct stance will become clear to him, and then he will be able to distinguish between the people of monotheism, the people of the Sunnah, the people of faith, and the people of ignorance and innovation.
In light of the mentioned evidences and proofs, it has become as clear as the sun that the Rightly Guided Caliphs and the majority of the Companions, may Allah be pleased with them, would enter the Prophet’s Mosque to perform prayers and would send salutations upon the Prophet Muhammad, peace be upon him, when entering and leaving the mosque during prayer, but they did not feel the need to go near the honored grave.