Introduction to Fiqh-us-Sunnah
'Aishah reports that the Prophet sallallahu alehi wasallam said: "Allah cursed the Jews and Christians [because] they took the graves of their prophets as mosques." This is related by al-Bukhari, Muslim, Ahmad, and an-Nasa' i .
Ahmad and Muslim record from Abu Marthad al-Ghanawi that the Prophet sallallahu alehi wasallam said: "Do not pray facing a grave and do not sit on one." They also record that Jundub ibn 'Abdullah al-Bajali heard the Prophet say, five days before he died: "The people before you took graves as mosques. I prohibit this to you."
'Aishah reports that Umm Salamah mentioned the churches she saw in Abyssinia and the pictures they contained to the Messenger of Allah. The Prophet said to her: "These are the people who, when a pious servant or pious man among them dies, build a mosque [place of worship] upon their graves and put those pictures in it. They are the worst of the whole creation in the sight of Allah." This is related by al-Bukhari, Muslim, and an-Nasa' i .
The Prophet is also reported to have said: "Allah curses those who visit the graves and take them as mosques and light lamps over them." Many scholars take this prohibition to be one of dislike, regardless of whether the grave 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 grave site is not valid. According to the Hanbali school, this applies only if there are three graves or more. If there is only one or two graves, then the prayer is valid although disliked if one prays facing a grave, otherwise it is not disliked.
Volume 2, Page 75: Churches and synagoguesAbu 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 a church [if one happened to be in a church at the time of salah]. Al-Bukhari says: "Ibn 'Abbas would pray in churches [under unusual circumstances] except for those with statues or sculptures." The Muslims of Najran wrote to 'Umar saying that they found no place cleaner or better to pray in than a church. 'Umar wrote to them: "Sprinkle it with water and leaves and pray therein." According to the Hanafi and Shaf'i schools, it is disliked to pray in such places in general.
Volume 2, Page 75a: Dunghills, slaughterhouses, middle of the roads, resting places of the camels near watering holes, bathrooms and on the roof of the "house of Allah"Ibn 'Umar relates that the Prophet sallallahu alehi wasallam prohibited salah in seven places: "dunghills, slaughterhouses, graveyards, middle of the road, bathhouses, watering places where the camels drink and rest, and on the roof of the house of Allah [the Ka'bah in Makkah]." This is related by Ibn 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 is the presence of impurities there. It is forbidden to pray at such places without any barrier, and if there is such a barrier one may pray, but it is disliked by the majority of the scholars, while Ahmad and other scholars of zahiri persuasion say it is prohibited. The reason why it is prohibited to pray in the resting places of the camels is the same as in the first two cases (i.e., the presence of impurities). The reason why it is prohibited to pray at the middle of the roads is because there is usually a lot of commotion, which could take one's heart away from the salah. As for praying on the roof of the Ka'bah, this contradicts the order to offer salah facing it. For this reason, many are of the opinion that a salah performed on top of the Ka'bah is invalid. The Hanafi school 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 impurities there, according to the majority of the scholars. Ahmad, Abu Thaur, and the Zahiriyyah hold that a salah offered in the bath-house is not valid.
Volume 2, Page 76: Prayer in the Ka'bahOffering salah in the Ka'bah is valid regardless of whether it is an obligatory prayer or a supererogatory prayer. Ibn 'Umar reports: "The Messenger 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 they opened the door, I was the first to come upon them and I asked Bilal: 'Did the Messenger of Allah pray [while he was inside]?' He said: 'Yes, between the two Yemeni pillars.'" This is related by Ahmad, al-Bukhari, and Muslim.