It is obligatory upon a Muslim that he should listen (to the ruler appointed over him) and…

Sahih Muslim Book 33 Hadith 61

Sahih Muslim #1839 a

The Book on Government 33:61

It has been narrated on the authority of Ibn 'Umar that the Prophet (ﷺ) said:

It is obligatory upon a Muslim that he should listen (to the ruler appointed over him) and obey him whether he likes it or not, except that he is ordered to do a sinful thing. If he is ordered to do a sinful act, a Muslim should neither listen to him nor should he obey his orders.

Chapter: The obligation of obeying leaders in matters that do not involve sin, but it is forbidden to obey them in sinful matters

Grade: Sahih