Is prayer valid if performed while one has the urge to urinate or defecate (Haqin or Mudafi' al-Akhbathayn)?
Chapter on the Description of Prayer
Al-Mughni
Book of Prayer
Primary text
It is disliked to pray while one has the urge to pass urine or feces until this need is satisfied, whether one fears missing the congregation or not. This is based on the Hadith of A'isha and the narration from Thawban that the Prophet (peace be upon him) said, "It is not lawful for a man to look into the private chamber of another man until he seeks permission, nor should he stand up to prayer while he is retaining urine." The rationale is that such a condition prevents complete concentration and presence of heart (Khushu') in the prayer.
Supporting text
If the person prays despite this urge, the prayer is valid. Ibn Abi Musa held that if the urge is severe enough to distract him from the prayer, he must repeat it based on the apparent meaning of the relevant Hadiths. Ibn Abd al-Barr argued that the Hadith of Thawban is not decisive evidence for the scholars of Hadith. Furthermore, retaining waste is considered a valid excuse for missing congregation and Friday prayers due to the general scope of the relevant prophetic statements.