a grave error. You were required to break off, leave the mosque, perform a new minor ablution, and then return in order to catch whatever remained of the congregational prayer. That was your duty. Remaining in the row while you are without ritual purity and praying with the people in that state is a serious mistake—do not repeat it. There is no blame on you for leaving and stepping out of the rows: if you can find an opening that lets you exit without passing between the worshippers, do so; otherwise, leave even if you must move through the rows, for you are excused in this matter. What is impermissible is to continue standing, bowing, and prostrating while you are not in a state of purity; that is a major error.
Question: If the imam discovers in the middle of the prayer that he does not have minor ablution, what is the ruling?
Answer: If a person realizes during his prayer that he is without minor ablution, he must break off, perform wuduʾ, and then begin the prayer anew. It is not permissible for him to continue the prayer while lacking ritual purity.
Covering the ʿawrah is a prerequisite for the prayer
Question: What is the ruling regarding someone who prayed while a portion of his ʿawrah (the part of the body that must be covered) was exposed, and he only found out after he had finished the prayer when another worshipper pointed it out to him? Is his prayer valid, or must he repeat it? Please advise us, and may Allah reward you.
Answer: There is no doubt that covering the ʿawrah is one of the conditions for the validity of the prayer whenever one is able to do so. Ibn ʿAbd al-Barr (may Allah have mercy on him) said: “The scholars unanimously agree that the prayer of someone who prays naked while able to clothe himself is invalid,” or words to that effect.