“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.”
Sunan Ibn Majah Book 24, Hadith 112