Fiqh-us-Sunnah, Volume 2: Places where offering prayer is prohibited
'Aishah reports that the Prophet sallallahu alehi wasallam said: "Allahcursed the Jews and Christians [because] they took the graves of their prophetsas mosques." This is related by al-Bukhari, Muslim, Ahmad, and an-Nasa' i.
Ahmad and Muslim record from Abu Marthad al-Ghanawi that the Prophetsallallahu alehi wasallam said: "Do not pray facing a grave and do not siton one." They also record that Jundub ibn 'Abdullah al-Bajali heard theProphet say, five days before he died: "The people before you took gravesas mosques. I prohibit this to you."
'Aishah reports that Umm Salamah mentioned the churches she saw in Abyssiniaand the pictures they contained to the Messenger of Allah. The Prophet said toher: "These are the people who, when a pious servant or pious man amongthem dies, build a mosque [place of worship] upon their graves and put thosepictures in it. They are the worst of the whole creation in the sight ofAllah." This is related by al-Bukhari, Muslim, and an-Nasa' i .
The Prophet is also reported to have said: "Allah curses those whovisit the graves and take them as mosques and light lamps over them." Manyscholars take this prohibition to be one of dislike, regardless of whether thegrave is in front of the imam or behind him. According to the zahiri school,this prohibition is one of complete forbiddance and as such, prayer at a gravesite is not valid. According to the Hanbali school, this applies only if thereare three graves or more. If there is only one or two graves, then the prayeris valid although disliked if one prays facing a grave, otherwise it is notdisliked.
Abu Musa al-Ash'ari and 'Umar ibn 'Abdulaziz prayed in a church.Ash-Sh'abiy, 'Ata, and Ibn Sireen did not see anything wrong with praying in achurch [if one happened to be in a church at the time of salah]. Al-Bukharisays: "Ibn 'Abbas would pray in churches [under unusual circumstances]except for those with statues or sculptures." The Muslims of Najran wroteto 'Umar saying that they found no place cleaner or better to pray in than achurch. 'Umar wrote to them: "Sprinkle it with water and leaves and praytherein." According to the Hanafi and Shaf'i schools, it is disliked topray in such places in general.
Ibn 'Umar relates that the Prophet sallallahu alehi wasallam prohibitedsalah in seven places: "dunghills, slaughterhouses, graveyards, middle ofthe road, bathhouses, watering places where the camels drink and rest, and onthe roof of the house of Allah [the Ka'bah in Makkah]." This is related byIbn Majah, 'Abd ibn Humaid, and at-Tirmizhi who said its chain is not strong.The reason why it is prohibited to pray on dunghills and in slaughterhouses isthe presence of impurities there. It is forbidden to pray at such placeswithout any barrier, and if there is such a barrier one may pray, but it isdisliked by the majority of the scholars, while Ahmad and other scholars of zahiripersuasion say it is prohibited. The reason why it is prohibited to pray in theresting places of the camels is the same as in the first two cases (i.e., thepresence of impurities). The reason why it is prohibited to pray at the middleof the roads is because there is usually a lot of commotion, which could takeone's heart away from the salah. As for praying on the roof of the Ka'bah, thiscontradicts the order to offer salah facing it. For this reason, many are ofthe opinion that a salah performed on top of the Ka'bah is invalid. The Hanafischool holds that it is allowed, but disliked as it does not honor the Ka'bah.The reason it is disliked to pray in bath-houses is the presence of impuritiesthere, according to the majority of the scholars. Ahmad, Abu Thaur, and theZahiriyyah hold that a salah offered in the bath-house is not valid.
Offering salah in the Ka'bah is valid regardless of whether it is anobligatory prayer or a supererogatory prayer. Ibn 'Umar reports: "TheMessenger of Allah entered the house [the Ka'bah] with 'Usamah ibn Zaid, Bilal,and 'Uthman ibn Talhah and they closed the door behind themselves. When theyopened the door, I was the first to come upon them and I asked Bilal: 'Did theMessenger of Allah pray [while he was inside]?' He said: 'Yes, between the twoYemeni pillars.'" This is related by Ahmad, al-Bukhari, and Muslim.