Many hadith have been related which warn against leading a congregation while one is disliked by them. Dislike here relates to one’s religious conduct and is based on a valid reason.
Ibn ‘Abbas relates that the Prophet said: “Three people’s prayers will not rise above their head the length of a hand’s span. [They are:] a man who leads a people in salah and they do not like him, a woman who has disobeyed her husband and he is dipleased with her, and two brothers who are estranged.” This is related by Ibn Majah. Al-‘lraqi says its chain is hasan.
‘Abdullah ibn ‘Amr relates that the Prophet sallallahu alehi wasallam said: “Allah does not accept prayers from three [types of] people: a man who leads a people and they dislike him, a man who attends the prayers after their time is finished, and a man who re-enslaves his freed slave.” This is related by Abu Dawud and Ibn Majah.
Elaborating upon it, at-Tirmizhi says: “It is disliked that a man should lead a people in salah while they dislike him. If the imam is not a wrongdoer, then the sin is upon those who don’t like him.”