All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
If the Imaam performs the prayer without being in a state of purity and then it becomes clear to him that he had performed the prayer in this condition, then his prayer is void and he is obliged to make it up. However, according to the most preponderant opinion of the scholars the people led in prayer [the congregation] are not obliged to make it up. That is because the prayer of the people led in prayer does not become invalid because of the invalidity of the prayer of their Imaam because of him not being in a state of purity; the thing which they [congregation] did not know (during the prayer). Rather, many scholars are of the view that the prayer of the congregation is absolutely not linked to the prayer of the Imaam in regard to its invalidity. The evidence about this is that Abu Hurayrah narrated that the Prophet said: "They [the Imaams] lead you in prayer, and if they do it properly, then you and them will reap a reward, but if they make mistakes, then you will reap a reward and they will be held responsible.” [Ahmad] For more benefit, refer to Fatwa 101586.
Allaah Knows best.