The root meaning of janābah (major ritual impurity) is distance. A person in this state is called junub because he keeps away from the place of prayer, or because he withdraws from people and remains apart from them until he bathes.
His saying, exalted is He, “unless merely passing through, until you have bathed”: the scholars differed over its meaning. Some said: “[It means:] unless you are travelling and cannot find water, in which case perform tayammum (dry ablution). He has forbidden a person in a state of major ritual impurity from prayer until he bathes” (1)—except when he is travelling and cannot find water, in which case he prays with tayammum. This was the view of Ali, Ibn Abbas, Said ibn Jubayr, and Mujahid, may Allah have mercy on them.
Others said that what is meant by “prayer” is the place of prayer, as in His saying, exalted is He: “monasteries, churches, synagogues” (al-Hajj 22:40). Its meaning, then, is: Do not approach the mosque while you are in a state of major ritual impurity, except when passing through it in order to leave it—for example, if one sleeps in the mosque and becomes in a state of major ritual impurity, or if this state comes upon him while the water is in the mosque, or his route passes through it. He may therefore pass through it but not remain there. This was the view of Abdullah ibn Masud, Said ibn al-Musayyib, al-Dahhak, al-Hasan, Ikrimah, al-Nakhai, and al-Zuhri. This was because some of the Ansar had doors opening into the mosque; they would enter a state of major ritual impurity, yet have no water with them and no passage except through the mosque. They were therefore granted permission to pass through it.
The scholars differed regarding this. Some permitted passing through it unconditionally; this was the view of al-Hasan, and it was also held by Malik and al-Shafii, may Allah have mercy on them. Others prohibited it unconditionally; this was the view of the adherents of legal reasoning. Others said that one should perform tayammum in order to pass through it.
As for remaining in the mosque, the majority of scholars do not permit it, on account of what we narrated from Aishah, may Allah be pleased with her: the Messenger of Allah, peace and blessings be upon him, said, “Turn these houses away from the mosque, for I do not permit the mosque to a menstruating woman or to one in a state of major ritual impurity.” (2) Ahmad, however, permitted remaining in it, and the hadith was deemed weak because one of its narrators is unknown. This was also the view of al-Muzani.
It is not permissible for one in a state of major ritual impurity to perform tawaf, just as it is not permissible for him to pray; nor is it permissible for him to recite the Quran. Abd al-Wahid ibn Ahmad al-Mulayhi informed us; Abd al-Rahman ibn Abi Shurayh informed us; Abu al-Qasim al-Baghawi informed us; Ali ibn al-Jad informed us; Shubah informed us; Amr ibn Murrah informed me, saying: I heard Abdullah ibn Salamah (3) say: I entered upon Ali, may Allah be pleased with him, and he said: “The Messenger of Allah, peace and blessings be upon him, would relieve himself, eat meat with us, and recite the Quran. Nothing would prevent him—or hold him back—from reciting the Quran except major ritual impurity.” (4)