Issue: If a sinful person is an imam whom one is unable to oppose, such as a person in authority, is prayer behind him valid?
The answer is: According to the established school, it is not valid. However, they make two exceptions: Friday prayer and Eid prayer, when they cannot be performed behind anyone else. Thus, if a town has only one congregational mosque and its imam is sinful, then one prays behind him.
Likewise, if there is only one place for the Eid prayer and its imam is sinful, we pray behind him, because if we were to refrain from praying behind him, we would miss the Friday prayer and the Eid prayer.
What if there is only this mosque in the town, its imam is sinful, and it is not a Friday or Eid prayer?
The answer is that, according to the established school, he prays alone and does not pray behind him. However, the correct view is that prayer behind him is valid, as mentioned previously.
Issue: If the imam is sinful according to your own conviction, but not sinful according to his own conviction—for example, he considers smoking lawful while you consider it unlawful—should you pray behind him?
The answer is: You should pray behind him. For if you were asked about him, “Is he sinful according to his own belief?” you would say, “No,” because he believes that this is lawful. Likewise, if a man does not hold that camel meat invalidates ablution, while you hold that it does, and he eats camel meat and then leads you in prayer, your prayer behind him is valid. Although you would regard his prayer as invalid if you yourself had done this, when he does it, you regard his prayer as valid. For this reason, the scholars, may Allah have mercy on them, said: Prayer behind—