“The Muslim is obliged to obey (the ruler) whether he likes it or not, unless he is commanded to commit an act of disobedience. If he is commanded to commit a sin then he should neither listen nor obey.” (Using translation from Ibn Mājah 2864)
عَنِ النَّبِيِّ ﷺ قَالَ السَّمْعُ وَالطَّاعَةُ عَلَى الْمَرْءِ فِيمَا أَحَبَّ أَوْ كَرِهَ إِلَّا أَنْ يُؤْمَرَ بِمَعْصِيَةٍ فَإِنْ أُمِرَ بِمَعْصِيَةٍ فَلَا سَمْعَ وَلَا طَاعَةَ