Answer: There are numerous evidences in Islam that prohibit taking graveyards as masjids. When the Prophet ﷺ prohibited taking graveyards as masjids, it meant:
- Not to perform sujood (prostration) on graves.
- Not to face graves during prayer.
- Not to supplicate toward graves.
- Not to build masjids on top of graves.
The Prophet ﷺ said:
“Do not pray toward a grave, and do not pray on a grave.”(Al-Mu’jam al-Kabir: 12051)
In another hadith, the Prophet ﷺ said:
“Do not sit on the graves, and do not pray toward them.”(Muslim: 972)
Additionally, Ibn Hibban narrated in his Sahih, from Anas ibn Malik, and Shaykh Muhammad Nasiruddin Al-Albani authenticated it in his Sahih Al-Jami’.
“The Prophet ﷺ prohibited praying toward the graves.” (Sahih ibn Hibban: 2002)
The Prophet ﷺ also prohibited:
“Building on graves, sitting on graves, or praying on graves.” (Musnad Abu Ya’la: 1020)
This narration was authenticated by Shaykh Muhammad Nasiruddin Al-Albani.
Scholarly Consensus:
The scholars unanimously agreed upon the prohibition of such actions.
Prohibition of Placing the Janazah in Front of the Qibla During Obligatory Prayers:
If praying toward a grave is prohibited, then placing a deceased body (janazah) in front of the Qibla during obligatory prayers is even more strongly prohibited. This is an emphasized prohibition.
Statement of Al-Mulla Al-Qari:
In his book Mirqatu Al-Mafatih, Al-Mulla Al-Qari made a powerful statement regarding this issue, which is worth reading.
Ruling on Praying While a Body is Placed in Front of the Qibla:
If a person knew that the Imam or the masjid committee placed a body in front of the Qibla during obligatory prayers and still prayed deliberately, they are sinful and must repeat their prayer.
This applies whether they prayed alone or behind the Imam. They must also seek forgiveness from Allah.
If a person prayed without knowing that a body was placed in front of the Qibla, their prayer is valid, and there is no sin upon them, inshaAllah ta'ala.
Anything I have said that is correct is from Allah, and anything incorrect is from myself and Shaytan.
— Answered by Ustadh Abdulrahman Hassan