The obligation of obeying leaders in matters that do not involve sin, but it is forbidden to obey them in sinful matters
وَحَدَّثَنِي حَرْمَلَةُ بْنُ يَحْيَى، أَخْبَرَنَا ابْنُ وَهْبٍ، أَخْبَرَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، أَخْبَرَهُ قَالَ حَدَّثَنَا أَبُو سَلَمَةَ بْنُ عَبْدِ الرَّحْمَنِ، عَنْ أَبِي هُرَيْرَةَ، عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم أَنَّهُ قَالَ " مَنْ أَطَاعَنِي فَقَدْ أَطَاعَ اللَّهَ وَمَنْ عَصَانِي فَقَدْ عَصَى اللَّهَ وَمَنْ أَطَاعَ أَمِيرِي فَقَدْ أَطَاعَنِي وَمَنْ عَصَى أَمِيرِي فَقَدْ عَصَانِي " .
It has been narrated on the authority of Abu Huraira that the Messenger of Allah (ﷺ) said: Whoso obeys me obeys God; and whose disobeys me disobeys God. Whoso obeys my commander obeys me, and whoso disobeys my commander disobeys me.