from the populace, and the Messenger of Allah ﷺ even contemplated setting fire to the houses of those who neglected the congregational and Friday prayers (1). What restrained him was the fact that they contained women and young children upon whom attendance is not obligatory, as he himself explained (2).
One corollary of this is that a waqf is invalid if it is dedicated to anything other than righteousness and devotion, just as the endowment of that mosque was declared void. Accordingly, a mosque erected over a grave must be demolished, and a body buried inside a mosque must be exhumed—so ruled Imam Ahmad and others. In Islam a mosque and a grave may never coexist: whichever of the two is the later addition must be removed, for the earlier enjoys precedence. If both are established simultaneously, the arrangement is still impermissible; the endowment is null, unlawful, and the prayers performed in such a mosque are invalid, because the Messenger of Allah ﷺ forbade it.