Know, then, that some jurists believed the sole reason why prayer in a graveyard is disliked lies in the likelihood of impurity, for the soil may be contaminated by the discharge that seeps from the deceased. Building on that assumption, they differentiated between a newly-dug cemetery and an old one, and between praying directly on the earth and praying with a barrier between the worshiper and the ground. Certainly, the presence of impurity on any piece of land is enough to bar prayer there—whether the place is a graveyard or not. Yet the primary object of the prohibition against praying at graves is not this.
Rather, the true reason is the fear that graves be taken as objects of worship. It has been shown that the Jews and Christians, whenever a righteous man among them died, would build a place of worship over his grave, and the Prophet—peace and blessings be upon him—said,
“May Allah curse the Jews and the Christians; they turned the graves of their prophets into mosques,”
warning against their practice.
In another report he prayed,
“O Allah, do not allow my grave to become an idol that is worshiped. Allah’s wrath is intense against a people who turned the graves of their prophets into places of worship.”
ʿĀʾishah, may Allah be pleased with her, remarked, “Had it not been for that, his grave would have been left open, but they feared it would be taken as a mosque.”
He also declared, “Those who came before you used to turn graves into places of worship. Beware—do not turn graves into places of worship, for I forbid you to do so.”