Now, because Allah has attributed the mosques to Himself—and the Prophet, peace and blessings be upon him, has likewise linked them to his Lord—He has permitted that they be exalted. Consequently, they possess sanctity, specific rulings, reverence, and veneration.
One such ruling is that it is not lawful for someone in a state of major ritual impurity (junub) to remain in the mosque unless he first performs wuḍūʾ (minor ablution). The Prophet, peace and blessings be upon him, said about the junub: “The angels do not enter a house in which there is a junub so long as he is in that state.” If the angels will not enter his own home, then his staying in the mosque while junub likewise offends them, for he either bars them from entering or causes them discomfort when they do enter. Therefore, we say that a person who is junub should not enter the mosque except after performing wuḍūʾ.
We make this allowance because the Companions (may Allah be pleased with them) used to sleep in the mosque, and when one of them became junub he would rise, perform wuḍūʾ, return, and lie down again. This occurred during the lifetime of the Prophet, peace and blessings be upon him, and he approved of it.
Another ruling concerning the mosques is that when a person enters he must not sit until he has prayed two rakʿahs, regardless of the time—morning, evening, night, day, at sunrise, or at sunset. The Prophet, peace and blessings be upon him, said: “When any of you enters the mosque, let him not sit until he has prayed two rakʿahs.” Indeed, while he was once delivering the Friday sermon, a man entered and sat down. The Prophet halted his sermon and asked him, “Have you prayed?” The man replied, “No.” He said, “Stand and pray two rakʿahs, but keep them brief.”