15.3 No obedience in sin
One matter that has been excluded from the obligation of obeying the ruler is when He orders a sin. This exclusion has been confirmed by text. Nafi’ reported on the authority of Ibnu ‘Umar that the Messenger of Allah (pbuh) said; “It is obligatory upon a Muslim that He should listen and obey whether He likes it or not, except when He is ordered to commit a sinful act. If He is ordered to do a sinful act, a Muslim should neither listen nor obey.” [Narrated by Muslim] The subject being addressed here is the case of a ruler ordering a Muslim to commit sin. It does not address the issue of a ruler being sinful. If the ruler committed the sin before you, without ordering you to commit it, you still have to obey him. Muslim reported on the authority of ‘Awf Ibnu Malik Al- Ashjai’, He said; “I heard the Messenger of Allah (pbuh) say:
‘The best of your Imams are those whom you love and they love you, and whom you pray for and they pray for you, and the worst of your Imams are those whom you hate and they hate you and you curse them and they curse you.’We asked; ‘O Messenger of Allah, shall we not then declare war on them?’ He (pbuh) said; ‘No, as long as they establish prayer among you. Beware! Whoever has a Waali (ruler) appointed over Him and He saw Him commit an act of disobedience to Allah, He should hate the Waali’s act of disobedience to Allah, but should not withdraw his hand from obedience.’” This serves as an evidence that what is intended by ordering a sinful act is ordering of the act itself by the ruler rather than the ruler himself committing it. If the ruler is seen committing a sin, it would not be lawful to disobey him, but if He ordered somebody to disobey Allah, then He should not be obeyed for there is no obedience to any created person in an act of disobedience to the Creator.