The ruling on building Masjids and places for Prayer near Graveyards
Question :
Some Masjids and places that have been prepared for the two 'Eid prayers and the prayer for seeking rain (Al- Istisqa') are placed on graveyards, such that the graveyard is in the direction of the Qiblah of the Masjid. In such situations there is nothing between the Masjid and the graves except for several meters. Some of these Masjids are directly attached to the graveyard. Some other places that have been prepared for the two Eid prayers and the prayer for rain are surrounded by a wall that separates them from the graveyard. Other places do not have a wall to separate them from the graveyard. So, what is the ruling?
Answer:
If these Masjids are not built for the sake of the graves, and the places of the two Eid prayers and the prayer for rain have not been arranged close to the graves for the sake of the graves as a way of honoring the persons in them or seeking extra reward and blessing by praying there due to their closeness to the graves, then building them and preparing them for prayer and drawing near to Allâh in them is permissible, and prayer in them is legislated. These places may be maintained by offering prayer in them, and other acts of drawing near to Allâh may be performed in them, and it is desired religiously. Whatever of these places is surrounded by a wall that separates them (the graves) from the Masjids, then that effort is sufficient for you. Whatever of them (the prayer places) is not surrounded by a fence, then a fence should be made for them to separate the graves from the Masjids and the places of the 'Eid prayer and the prayer for rain. If it is easy to make a space between the wall of the Masjid and the prayer area for the Eid and rain prayers, and the wall of the graves, then this is safer. However, if the establishment of the Masjids around the graves is for the sake of honoring the graves, then it is not permissible to pray in them and it is obligatory to tear them (the Masjids) down. This is because establishing them in this manner is from the means that lead to associating the people of the graves as partners with Allâh (ie., Shirk). Indeed it has been confirmed from the Prophet that he said:
"Do not pray towards the graves and do not sit on them." It also has been authenticated from him that he said:
"Verily, those who were before you all, used to take the graves of their Prophets and righteous people as Masjids. So, do not take the graves as Masjids, for verily I prohibit you all from that."
Both of these Hadiths were recorded by Muslim in his Sahih. The Hadiths on this subject are well known. And success comes from Allah. May Allâh send blessings and peace upon our Prophet Muhammad.
Source:
The Permanent Committee
Fatawa Islamiyah, Vol. 3 Pages 35-36-37