“This in no way contradicts what is firmly established in Sahih al-Bukhari, namely the Prophet’s—may Allah bless him and grant him peace—instruction during his final illness that all doors opening onto the mosque be closed except the door of Abu Bakr al-Siddiq. The dispensation granted to ‘Ali had occurred while the Prophet was still alive, because Fatimah needed to pass from her own house to her father’s; the exemption was therefore a kindness shown to her. After the Prophet’s death that reason disappeared, and it became necessary to open Abu Bakr’s door so that he could come out to the mosque and lead the people in prayer, for he was the caliph over them after the Prophet’s demise. The report thus contains an implicit indication of his succession.”
That said, it appears that the Prophet’s—peace and blessings be upon him—order to block the side-openings (khawkha) and the doors falls under the principle of blocking the means (sadd al-dhara’iʿ), because their presence would turn the mosque into a thoroughfare, something that is forbidden, as will be mentioned under the prohibitions, paragraph (12). For this reason al-Hafiz, while listing the benefits of the hadith, stated:
“Mosques are to be protected from being used as passageways except when necessity demands.”
A similar remark will be quoted from al-Qurtubi in the place to which we have alluded.
It is permissible to build mosques on:
(a) The former places of worship of unbelievers, once they have been demolished and their distinguishing features removed. Ṭalq b. ʿAli (may Allah be pleased with him) said: “We went as a delegation to the Prophet ﷺ, pledged our allegiance to him, and prayed with him. We told him that in our land there was a church (bīʿa)… He said, ‘Go forth, and when you reach your country, demolish your church… and make it into a mosque.’”
The report is given here in abridged form. Its full wording, after his statement “there is a church in our land,” runs: “We asked him to grant us some of the surplus water from his ablution. He called for water, performed ablution and rinsed his mouth, then poured it into a waterskin and instructed us, saying:”