When a person loses wudu’ or ablution during prayer, he should immediately leave the prayer, make wudu’ again, and then come again to resume his prayer in the same place (if others have not closed the gap), as long as he has not spoken to anyone. The prayer of the Imam is still valid if a person praying after him loses his wudu’ during the prayer.
Dr. Muzammil Siddiqi, former President of the Islamic Society of North America, states the following: “If a person breaks his wudu’ during the prayer, whether praying alone or in congregation, he should immediately leave the prayer, go to renew the wudu’, and then he can resume his prayer from where he left as long as he did not speak to anyone. If he spoke to anyone, then he has to repeat the whole prayer. This rule is according to a Prophetic Hadith reported in the Sunnah of Ibn Majah and that of Ad-Darmi. It does not make any difference whether a person is in the first line or any other line, he must leave the prayer immediately after breaking the wudu’. (He can walk in front of the others praying in order to leave, but he must not walk in front of the Imam). If the Imam has to leave the prayer in this situation, he has to place someone else in his place to continue leading the prayer.”