كتاب الإمارة
33  
The Book on Government
(8)
Chapter: The obligation of obeying leaders in matters that do not involve sin, but it is forbidden to obey them in sinful matters
(8)
باب وُجُوبِ طَاعَةِ الأُمَرَاءِ فِي غَيْرِ مَعْصِيَةٍ وَتَحْرِيمِهَا فِي الْمَعْصِيَةِ ‏‏
Sahih Muslim 1838 e

It has been narrated on the authority of Yahya b. Husain who learnt the tradition from his grandmother. Umm Husain. He said':

I heard her say: I performed Hajjat-ul-Wada' in the company of the Messenger of Allah (ﷺ). He said a lot of things (on this occasion). Then I heard him say: If a maimed slave is appointed a commander over you the narrator says: I think she said:" a black stave" who leads you according to the Book of Allah, then listen to him and obey him.
وَحَدَّثَنِي سَلَمَةُ بْنُ شَبِيبٍ، حَدَّثَنَا الْحَسَنُ بْنُ أَعْيَنَ، حَدَّثَنَا مَعْقِلٌ، عَنْ زَيْدِ بْنِ أَبِي، أُنَيْسَةَ عَنْ يَحْيَى بْنِ حُصَيْنٍ، عَنْ جَدَّتِهِ أُمِّ الْحُصَيْنِ، قَالَ سَمِعْتُهَا تَقُولُ، حَجَجْتُ مَعَ رَسُولِ اللَّهِ صلى الله عليه وسلم حَجَّةَ الْوَدَاعِ - قَالَتْ - فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم قَوْلاً كَثِيرًا ثُمَّ سَمِعْتُهُ يَقُولُ ‏ "‏ إِنْ أُمِّرَ عَلَيْكُمْ عَبْدٌ مُجَدَّعٌ - حَسِبْتُهَا قَالَتْ - أَسْوَدُ يَقُودُكُمْ بِكِتَابِ اللَّهِ فَاسْمَعُوا لَهُ وَأَطِيعُوا ‏"‏ ‏.‏
Reference : Sahih Muslim 1838e
In-book reference : Book 33, Hadith 60
USC-MSA web (English) reference : Book 20, Hadith 4532
  (deprecated numbering scheme)