Praise be to Allah.Praise be to Allaah.
Prayers should not be offered in mosques in which there are graves. The graves should be dug up and the remains transferred to the public graveyards, with each set of remains placed in an individual grave as with all other graves. It is not permissible for graves to be left in mosques, whether that is the grave of a wali (“saint”) or of anyone else, because the Messenger (peace and blessings of Allaah be upon him) forbade that and warned against that, and he cursed the Jews and Christians for doing that. It was narrated that he (peace and blessings of Allaah be upon him) said: “May Allah curse the Jews and the Christians, for they took the graves of their Prophets as places of worship.” ‘Aa’ishah (may Allaah be pleased with her) said, “He was warning against what they had done.” Narrated by al-Bukhaari, 1330, Muslim, 529.
And when Umm Salamah and Umm Habeebah told him about a church in which there were images, he (peace and blessings of Allaah be upon him) said: “When a righteous man died among them, they would build a place of worship over his grave and put those images in it. They are the most evil of mankind before Allaah.” (Saheeh, agreed upon. Al-Bukhaari, 427; Muslim, 528)
And he (peace and blessings of Allaah be upon him) said: “Those who came before you took the graves of their Prophets and righteous people as places of worship. Do not take graves as places of worship – I forbid you to do that.” (Narrated by Muslim in his Saheeh, 532, from Jundab ibn ‘Abd-Allaah al-Bajali). So the Prophet (peace and blessings of Allaah be upon him) forbade taking graves as places of worship and he cursed those who do that, stating that they are the most evil of mankind. So we must beware of that.
It is known that everyone who prays at a grave is taking it as a place of worship, and whoever builds a mosque over a grave has taken it as a place of worship. So we must keep graves far away from the mosques and not put graves inside mosques, in obedience to the command of the Prophet (peace and blessings of Allaah be upon him) and so as to avoid the curse issued by our Lord against those who build places of worship over graves, because when a person prays in a mosque in which there is a grave, the Shaytaan may tempt him to call upon the deceased or to seek his help, or to pray to him or prostrate to him, thus committing major shirk; and because this is the action of the Jews and Christians and we are obliged to differ from them and to keep away from their ways and their evil actions. But if the graves are ancient and a mosque was built over them, then it should be knocked down, because this is an innovated thing, as was stated by the scholars, and so as to avoid the means that may lead to shirk. And Allaah is the Source of strength.