“…No one is to pray in a mosque that sits among the graves except the funeral prayer.” This statement is decisive for the point we have been making.
The explicit wording cited from Aḥmad is further corroborated by the report from Anas: “He disliked that a mosque be built between graves.”
This plainly shows that the wall of a mosque is not a sufficient barrier between it and a grave; indeed, the wording may imply a categorical prohibition on constructing a mosque amid graves altogether. That view is the sounder one, for it most effectively blocks the avenues that lead to idolatry.
Shaykh al-Islām Ibn Taymiyyah states in al-Iqtiḍāʾ:
“The structure built over the grave of Abraham, peace be upon him, remained sealed off—no one could enter it—until about the beginning of the fourth century. It is said that a woman connected to the caliphs saw a dream concerning it and ordered it to be opened for that reason. Others say that when the Christians seized control of those regions they breached it. After the later Muslim reconquests it was left as a mosque, yet the upright scholars among our shaykhs would not pray in any part of that structure,