Compiled by Imam Yahya ibn Sharaf al-Nawawi
وعن ابن عمر رضي الله عنهما عن النبى صلى الله عليه وسلم قال: “على المرء المسلم السمع والطاعة فيما أحب وكره، إلا أن يؤمر بمعصية، فإذا أمر بمعصية فلا سمع ولا طاعة” ((متفق عليه))
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].