Nullifying Ablution During Prayer
What happens if the Imam nullifies his ablution during the prayer? Or what if he suddenly recalls that he in fact was not in a state of purity in the first place? What should he do? Is the prayer of the people praying behind him still valid or do they need to make up all or part of it?
If the Imam enters the state that nullifies his ablution or prayer, or remembers during the prayer that he did not perform ablution, then he should come out from prayer and appoint someone from the attendees who can lead them to completion. This has been narrated from `Umar, `Ali, ‘Alqamah and ‘Ataa’ (may Allah be pleased with them). If he did not appoint anyone and the people prayed individually, this would be acceptable, and this is the opinion taken by Imam Ash-Shafi`i. If he elected someone and advanced him to lead them, that is also permitted.
“When ‘Umar ibn Al-Khattab (may Allah be pleased with him) was stabbed, he took Abdur-Rahman ibn ‘Awf who led the prayer to completion.” (Al-Bukhari)
And the reason for this deduction is that ‘Umar did so in the presence of a number of the Companions and others and no one opposed this act, so it became a consensus (ijma‘). If the Imam remembers that he is not in a state of purity, he should indicate to the followers to remain as they are and purify himself and come back to lead them. The evidence for this is the following hadith:
The Prophet (peace be upon him) entered into the Fajr prayer (Dawn) and indicated to the people that they should stay in their places. Then he came back to lead them and water was dripping from his head. (Abu Dawud)
Commenting on this hadith, Imam Al-Khatabi says:
In this hadith there is an evidence that if one is leading the people in prayer while being in a state of impurity and the people do not know of it, then their prayer is unaffected and there is no need for them to repeat it. But the Imam has to repeat his prayer. (Ma‘alim As-Sunan by Al-Khatabi)
If one is praying (either as Imam or follower or individually) and recalls that he had wiped over his socks during ablution while the duration of wiping had expired, he should terminate his prayer because his ablution is incorrect. This is what has been quoted from Imam Ahmad and Ash-Shafi‘i. (Al-Mughni)
Source: Islamqa. info