Sahih Bukhari – Hadith No : 7231

Narrated `Abdullah: The Prophet said, “A Muslim has to listen to and obey (the order of his ruler) whether he likes it or not, as long as his orders involve not one in disobedience (to Allah), but if an act of disobedience (to Allah) is imposed one should not listen to it or obey it. (See Hadith No. 203, Vol. 4)

Hadith In Arabic Text :

حدثنا مسدد، حدثنا يحيى بن سعيد، عن عبيد الله، حدثني نافع، عن عبد الله رضى الله عنه عن النبي صلى الله عليه وسلم قال ‏”‏ السمع والطاعة على المرء المسلم، فيما أحب وكره، ما لم يؤمر بمعصية، فإذا أمر بمعصية فلا سمع ولا طاعة ‏”‏‏.‏

Chapter : Judgments (Ahkaam) – كتاب الأحكام