in the open desert, so that no one would pray at his grave, turn it into a mosque, and then (1) make his grave an idol.
While the Prophet’s chamber remained detached from the mosque up to the time of al-Walīd ibn ʿAbd al-Malik, the Companions and the Successors never entered it—neither to perform any prayer there, nor to rub themselves (2) against the grave, nor to supplicate within it. All of those acts they confined to the mosque proper.
Whenever the early generations among the Companions and the Successors offered greetings (3) to him and then wished to invoke Allah, they would turn toward the qiblah and not toward the grave.
As for standing to convey salutations (4), Abū Ḥanīfah said that one should also face the qiblah and not the grave.
Most of the leading jurists, however, held that one faces the grave only for the greeting itself. None of the imams ever said that the supplicant should face the grave while making duʿāʾ; the sole statement to that effect is a fabricated tale attributed to Mālik, and his actual view is the opposite. The imams are unanimously agreed that the Prophet’s grave ﷺ is neither to be touched nor kissed.
All of this is meant to safeguard pure monotheism, for one of the fundamental roots of associating partners with Allah is turning graves into places of worship, as a group of the early scholars explained concerning the Almighty’s words, “And they said, ‘Do not…’”