all sorts of fine distinctions: between a new cemetery and an old one, between having a barrier between the worshipper and the soil or not, holding that any impure ground bars the validity of prayer whether it is a graveyard or not. Yet the main purpose of the Prophet’s prohibition against praying at gravesides is none of this, for he clarified that the Jews and Christians, whenever a righteous man died among them, would build a mosque over his grave.
He then said: “It is also related that he prayed: Allahumma la tajʿal qabri wathanan yuʿbad (O Allah, do not turn my grave into an idol that is worshipped). The wrath of Allah is severe against a people who take the graves of their prophets as places of worship.”
Next he cited the ḥadith of ʿĀʾishah and others mentioned earlier, together with the forthcoming report of Jundub: “Those who came before you used to turn graves into mosques. Beware—do not make graves into mosques, for I forbid you to do that.” He then said:
“All of this shows you that the reason is not the suspicion of impurity but the fear that they will be taken as idols, just as al-Shāfiʿī, may Allah have mercy on him, said: ‘I dislike that any created being be so venerated that his grave becomes a mosque, lest temptation befall him and those who come after him.’ The same point was noted by Abū Bakr al-Athram in his Nāsikh al-Ḥadīth wa-Mansūkh and by other followers of Aḥmad as well as many scholars. The grave of the Prophet ﷺ—or of any righteous man—was never exhumed, and a single grave carries no inherent impurity. He ﷺ himself pointed to the real cause when he said, ‘Allahumma la tajʿal qabri wathanan yuʿbad,’ and when he said, ‘Those before you used to make graves into mosques, so do not make graves into mosques.’ Those people merely erected shrines over graves where no impurity existed.
Muslim also reports in his Ṣaḥīḥ, on the authority of Abū Marthad al-Ghanawī, that the Prophet ﷺ said: ‘Do not pray facing graves and do not sit on them.’ For he ﷺ also said: ‘Whenever one of their men died…’