He was asked about a preacher who came for Friday prayer, but the people refused to pray behind him because he adhered to a religious innovation: “What kind of innovation precludes praying behind him?”
He replied:
They have no right to prevent anyone from performing the Eid and Friday prayers, even if the imam is sinful. Nor may they abandon Friday prayer and similar prayers because of the imam’s sinfulness. Rather, they must perform these prayers behind the imam, even if he is sinful. If they suspend them because of the imam’s sinfulness, they are among the people of innovation. This is the position of al-Shāfi‘ī, Ahmad and others.
The scholars differed only concerning an imam who is sinful or adheres to religious innovation when it is possible to pray behind an upright imam.
One view is that prayer behind him is valid even if he is sinful. This is the position of al-Shāfi‘ī, of Ahmad according to one of the two reports from him, and of Abū Hanīfah.
Another view is that prayer behind a sinful imam is invalid when it is possible to pray behind an upright imam. This is one of the two positions reported from Mālik and Ahmad. And Allah knows best.