صحيح البخاري Sahih Bukhari كتاب الأحكام The Book of Al-Ahkam (Judgements)
بَابُ السَّمْعِ وَالطَّاعَةِ لِلإِمَامِ مَا لَمْ تَكُنْ مَعْصِيَةً:

(4) Chapter. To listen to and obey one’s Imam (Muslim ruler) as long as his orders involve not one in disobedience (to Allah).

4 hadith
Hadith 7142
حَدَّثَنَا مُسَدَّدٌ ، حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ ، عَنْ شُعْبَةَ ، عَنْ أَبِي التَّيَّاحِ ، عَنْ أَنَسِ بْنِ مَالِكٍ رَضِيَ اللَّهُ عَنْهُ ، قَالَ : قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ : " اسْمَعُوا وَأَطِيعُوا ، وَإِنِ اسْتُعْمِلَ عَلَيْكُمْ عَبْدٌ حَبَشِيٌّ كَأَنَّ رَأْسَهُ زَبِيبَةٌ " .
Narrated Anas bin Malik: Allah's Apostle said, "You should listen to and obey, your ruler even if he was an Ethiopian (black) slave whose head looks like a raisin."
Hadith Reference Sahih Bukhari / The Book of Al-Ahkam (Judgements) / Hadith: 7142
Hadith Grading محدثین: أحاديث صحيح البخاريّ كلّها صحيحة
Hadith 7143
حَدَّثَنَا سُلَيْمَانُ بْنُ حَرْبٍ ، حَدَّثَنَا حَمَّادٌ ، عَنِ الْجَعْدِ ، عَنْ أَبِي رَجَاءٍ ، عَنِ ابْنِ عَبَّاسٍ يَرْوِيهِ ، قَالَ : قَالَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ : "مَنْ رَأَى مِنْ أَمِيرِهِ شَيْئًا فَكَرِهَهُ فَلْيَصْبِرْ ، فَإِنَّهُ لَيْسَ أَحَدٌ يُفَارِقُ الْجَمَاعَةَ شِبْرًا فَيَمُوتُ ، إِلَّا مَاتَ مِيتَةً جَاهِلِيَّةً " .
Narrated Ibn `Abbas: The Prophet said, "If somebody sees his Muslim ruler doing something he disapproves of, he should be patient, for whoever becomes separate from the Muslim group even for a span and then dies, he will die as those who died in the Pre-lslamic period of ignorance (as rebellious sinners). (See Hadith No. 176 and 177)
Hadith Reference Sahih Bukhari / The Book of Al-Ahkam (Judgements) / Hadith: 7143
Hadith Grading محدثین: أحاديث صحيح البخاريّ كلّها صحيحة
Hadith 7144
حَدَّثَنَا مُسَدَّدٌ ، حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ ، عَنْ عُبَيْدِ اللَّهِ ، حَدَّثَنِي نَافِعٌ ، عَنْ عَبْدِ اللَّهِ رَضِيَ اللَّهُ عَنْهُ ، عَنِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ ، قَالَ : " السَّمْعُ وَالطَّاعَةُ عَلَى الْمَرْءِ الْمُسْلِمِ فِيمَا أَحَبَّ وَكَرِهَ مَا لَمْ يُؤْمَرْ بِمَعْصِيَةٍ ، فَإِذَا أُمِرَ بِمَعْصِيَةٍ فَلَا سَمْعَ وَلَا طَاعَةَ " .
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 Reference Sahih Bukhari / The Book of Al-Ahkam (Judgements) / Hadith: 7144
Hadith Grading محدثین: أحاديث صحيح البخاريّ كلّها صحيحة
Hadith 7145
حَدَّثَنَا عُمَرُ بْنُ حَفْصِ بْنِ غِيَاثٍ ، حَدَّثَنَا أَبِي ، حَدَّثَنَا الْأَعْمَشُ ، حَدَّثَنَا سَعْدُ بْنُ عُبَيْدَةَ ، عَنْ أَبِي عَبْدِ الرَّحْمَنِ ، عَنْ عَلِيٍّ رَضِيَ اللَّهُ عَنْهُ ، قَالَ : " بَعَثَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ سَرِيَّةً ، وَأَمَّرَ عَلَيْهِمْ رَجُلًا مِنَ الْأَنْصَارِ وَأَمَرَهُمْ أَنْ يُطِيعُوهُ ، فَغَضِبَ عَلَيْهِمْ ، وَقَالَ : أَلَيْسَ قَدْ أَمَرَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ أَنْ تُطِيعُونِي ، قَالُوا : بَلَى ، قَالَ : قَدْ عَزَمْتُ عَلَيْكُمْ لَمَا جَمَعْتُمْ حَطَبًا وَأَوْقَدْتُمْ نَارًا ثُمَّ دَخَلْتُمْ فِيهَا ، فَجَمَعُوا حَطَبًا فَأَوْقَدُوا نَارًا ، فَلَمَّا هَمُّوا بِالدُّخُولِ فَقَامَ يَنْظُرُ بَعْضُهُمْ إِلَى بَعْضٍ ، قَالَ بَعْضُهُمْ : إِنَّمَا تَبِعْنَا النَّبِيَّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ فِرَارًا مِنَ النَّارِ أَفَنَدْخُلُهَا ، فَبَيْنَمَا هُمْ كَذَلِكَ ، إِذْ خَمَدَتِ النَّارُ وَسَكَنَ غَضَبُهُ ، فَذُكِرَ لِلنَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ ، فَقَالَ : لَوْ دَخَلُوهَا مَا خَرَجُوا مِنْهَا أَبَدًا ، إِنَّمَا الطَّاعَةُ فِي الْمَعْرُوفِ " .
Narrated `Ali: The Prophet sent an army unit (for some campaign) and appointed a man from the Ansar as its commander and ordered them (the soldiers) to obey him. (During the campaign) he became angry with them and said, "Didn't the Prophet order you to obey me?" They said, "Yes." He said, "I order you to collect wood and make a fire and then throw yourselves into it." So they collected wood and made a fire, but when they were about to throw themselves into, it they started looking at each other, and some of them said, "We followed the Prophet to escape from the fire. How should we enter it now?" So while they were in that state, the fire extinguished and their commander's anger abated. The event was mentioned to the Prophet and he said, "If they had entered it (the fire) they would never have come out of it, for obedience is required only in what is good." (See Hadith No. 629. Vol. 5)
Hadith Reference Sahih Bukhari / The Book of Al-Ahkam (Judgements) / Hadith: 7145
Hadith Grading محدثین: أحاديث صحيح البخاريّ كلّها صحيحة