The reason of including the grave of the Prophet (صلى الله عليه وسلم) within his Masjid
Q: It is known that it is impermissible to bury the dead in Masjids (mosques), and it is also impermissible to offer Salah (Prayer) in a Masjid containing a grave. What is the reason behind including the grave of the Prophet (صلى الله عليه وسلم) and some of his Sahabah (Companions) in Al-Masjid Al-Nabawi (the Prophet’s Mosque in Madinah)?
A: It was authentically reported from the Messenger of Allah (صلى الله عليه وسلم) that he stated, “May Allah curse the Jews and the Christians; they have taken the graves of their prophets as Masjids (i.e. places of worship).” (Agreed upon its authenticity by Imams Al-Bukhari and Muslim). It was also authentically reported from ‘Aishah (رضی اللہ عنھا) “that Um Salamah and Um Habibah told the Messenger of Allah (صلى الله عليه وسلم) about a church they saw in Abyssinia and the pictures it contained. He (صلى الله عليه وسلم) said, “When a righteous person among these people dies, they build a Masjid (place of worship) on his grave, and then make such images in it. These will be the evilest of creatures in the Sight of Allah on the Day of Resurrection.” (Agreed upon by Al-Bukhari and Muslim)
It was also related by Muslim in his Sahih (authentic) Book of Hadith, on the authority of Jundub ibn ‘Abdullah Al-Bajali that he heard the Messenger of Allah (صلى الله عليه وسلم) saying, “Allah has taken me as a Khalil (close friend) as He took Ibrahim (Abraham) as a Khalil. Were I to have taken anyone from among my Ummah (nation) as a Khalil, I would have taken Abu Bakr as a Khalil.
Beware! Those who preceded you used to take the graves of their Prophets and righteous people as Masjids (places of worship). Do not take graves as Masjids; I forbid you to do that.” It was also related by Muslimon the authority of Jabir (رضي الله عنه) that the Prophet (صلى الله عليه وسلم): “forbade plastering the graves, sitting on them, or building over them.” These Sahih Hadiths and others indicate the prohibition of taking graves as places of worship and cursing those who do so. They also indicate the prohibition of building on graves, erecting domes over them and plastering them, as this is one of the means leading to Shirk (associating others with Allah in His Divinity or worship) and worshipping the inhabitants of the graves instead of Allah, which took place in the past and continues to this present day.
The Muslims everywhere should beware of what the Messenger of Allah (صلى الله عليه وسلم) prohibited, and not be misled by what many people did. Al-Haqq (the Truth) is the sought-after goal for every Mu’min (believer); whenever they find it, they should follow it. Al-Haqq is known through the Qur’an and the Sunnah (whatever is reported from the Prophet), not through the opinions and deeds of people. The Messenger of Allah (صلى الله عليه وسلم) and the Sahabah were not buried in the Masjid, but in the house of ‘Aishah. However, when the Masjid was expanded in the era of Al-Walid ibn ‘Abdul-Malik, he included the room in the Masjid. This was at the end of the first century. This is not considered burying in the Masjid; the Messenger of Allah (صلى الله عليه وسلم) and the two Sahabah were not carried to the terrain of the Masjid, but the room in which they were buried was included in the Masjid for the purpose of expansion. This is not supporting evidence for permitting anyone to build on the graves, turn them into Masjids or bury the dead in Masjids, according to the previously mentioned Sahih Hadiths that forbid this. What was done by Al-Walid is no excuse that justifies contradicting the Sunnah authentically reported from the Messenger of Allah. May Allah grant us success!
[Majmoo’al-Fataawa Ibn Baaz, Vol.: 4, pp 337 – 338]