The obligation of obeying leaders in matters that do not involve sin, but it is forbidden to obey them in sinful matters Sahih Muslim 1835 f

Arabic hadith text
وَحَدَّثَنَا مُحَمَّدُ بْنُ رَافِعٍ، حَدَّثَنَا عَبْدُ الرَّزَّاقِ، حَدَّثَنَا مَعْمَرٌ، عَنْ هَمَّامِ بْنِ مُنَبِّهٍ، عَنْ أَبِي هُرَيْرَةَ، عَنِ النَّبِيِّ صلى الله عليه وسلم بِمِثْلِ حَدِيثِهِمْ ‏.‏
Translation

Hammam b. Munabbih has transmitted this hadith on the authority of Abu Huraira.