The obligation of obeying leaders in matters that do not involve sin, but it is forbidden to obey them in sinful matters Sahih Muslim 1840 c
Arabic hadith text
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا وَكِيعٌ، وَأَبُو مُعَاوِيَةَ عَنِ الأَعْمَشِ، بِهَذَا الإِسْنَادِ نَحْوَهُ .
Translation
This hadith has been transmitted on the authority of A'mash.