“When you grasp this divergence over the underlying cause, it becomes clear that the correct course is to abide by the purport of the prohibition itself—namely, that it is forbidden, just as Aḥmad and the Ẓāhirī scholars have held. As for the Prophet’s instruction to pray in sheepfolds, that is merely a declaration of permissibility, not an obligation, by unanimous agreement.
The detailed discussion will appear in its proper place, God willing.
Fourth: The bathhouse, on the strength of the previously cited hadith, namely his ﷺ statement: ‘The whole earth is a place of prostration except for the graveyard and the bathhouse.’ The ruling on praying in a bathhouse is therefore the same as praying in a graveyard—in other words, it is prohibited—according to the explicit wording of the hadith. This is the position of Aḥmad and Ibn Ḥazm, and they went so far as to declare a prayer performed there invalid. In Nayl al-Awṭār it is stated:
‘Abū Thawr said: “One is not to pray in a bathhouse, in deference to the plain sense of the hadith.” The Ẓāhirīs adopted the same view. It is related from Ibn ʿAbbās that he said: “Let no one pray facing a refuse heap, inside a bathhouse, or in a graveyard.” Ibn Ḥazm commented: “We know of no Companion who disagreed with Ibn ʿAbbās on this point.” Similar reports have reached us from Nāfiʿ ibn Jubayr ibn Muṭʿim, Ibrāhīm al-Nakhaʿī, Khaythama, and ʿAlāʾ ibn Ziyād from his father. Ibn Ḥazm further said: “Prayer is not permissible in a bathhouse—whether at its entrance, anywhere within its boundaries, on its roof, over the furnace vault, or on the tops of its walls—whether the structure is intact or in ruins. However, if so much of the building collapses that the place is no longer called a bathhouse, then prayer on that ground becomes permissible.”’
The majority, on the other hand, consider that praying in a bathhouse is valid provided one is ritually pure, though it remains disliked. They base this on general texts such as the hadith, ‘Wherever the time for prayer overtakes you, pray,’ and interpret the prohibition as applying to a bathhouse that is actually defiled.