Riyad as-Salihin

Riyad as-Salihin 662

Obligation of Obedience to the Ruler in what is Lawful and Prohibition of Obeying them in what is Unlawful
Arabic hadith text
وعن ابن عمر رضي الله عنهما عن النبى صلى الله عليه وسلم قال‏:‏ “على المرء المسلم السمع والطاعة فيما أحب وكره، إلا أن يؤمر بمعصية، فإذا أمر بمعصية فلا سمع ولا طاعة” ‏(‏‏(‏متفق عليه‏)‏‏)‏
Translation
Ibn 'Umar (May Allah be pleased with them) reported

The Prophet (ﷺ) said, "It is obligatory upon a Muslim to listen (to the ruler) and obey whether he likes it or not, except when he is ordered to do a sinful thing; in such case, there is no obligation to listen or to obey."[Al-Bukhari and Muslim].