Praying in a Masjid having a grave

Q: What is the ruling on offering Salah (Prayer) in a Masjid (mosque) where there is a grave? A person whom we asked (Part No. 1; Page No. 141) said that there is no harm whether the grave was outside the Masjid or annexed to it. He said that the Sahabah (Companions of the Prophet) did not object to burying the Prophet (peace be upon him), Abu Bakr, or `Umar in the Masjid. If the grave is annexed to the Masjid but not in the direction of the Qiblah (Ka`bah-direction faced in Prayer), it is Makruh (disliked) to offer Salah in it. However, you can offer Salah if the grave is in the direction of the Qiblah but not annexed to Masjid. Please, advise. May Allah reward you the best!

A: According to the relevant Hadiths, it is prohibited to build Masjids over graves as a part of the Masjid, for this leads to Shirk (associating others with Allah in His Divinity or worship). It is also prohibited to offer Salah at any spot of the Masjid built over graves because this leads to Shirk or to offer Salah beside graves where there is no Masjid, because this counts as taking them Masjids. On the other hand, the graves of the Prophet (peace be upon him) and his two Companions (may Allah be pleased with them) were outside the Masjid. They were buried in the room of `Aishah (may Allah be pleased with her). When the Masjid was expanded during the caliphate of Al-Walid ibn `Abdul-Malik, the room was included by the order of Al-Walid without consulting scholars. In conclusion, the Masjid of the Messenger (the Prophet's Mosque) was not built over the graves, all praise is due to Allah.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.