كتاب الإمارة
33  
The Book on Government
(10)
Chapter: The obligation of fulfilling oaths of allegiance is owed to the first of two Caliphs
(10)
باب الْوَفَاءِ بِبَيْعَةِ الْخُلَفَاءِ الأَوَّلِ فَالأَوَّلِ ‏‏
Sahih Muslim 1843

It has been narrated on the authority of 'Abdullah who said:

The Messenger of Allah (ﷺ) said: After me there will be favouritism and many things that you will not like. They (his Companions) said: Messenger of Allah, what do you order that one should do if anyone from us has to live through such a time? He said: You should discharge your own responsibility (by obeying your Amir), and ask God for your right (by guiding the Amir to the right path or by replacing him by one more just and God-fearing).
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا أَبُو الأَحْوَصِ، وَوَكِيعٌ، ح وَحَدَّثَنِي أَبُو سَعِيدٍ، الأَشَجُّ حَدَّثَنَا وَكِيعٌ، ح وَحَدَّثَنَا أَبُو كُرَيْبٍ، وَابْنُ، نُمَيْرٍ قَالاَ حَدَّثَنَا أَبُو مُعَاوِيَةَ، ح وَحَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، وَعَلِيُّ بْنُ خَشْرَمٍ، قَالاَ أَخْبَرَنَا عِيسَى بْنُ يُونُسَ، كُلُّهُمْ عَنِ الأَعْمَشِ، ح وَحَدَّثَنَا عُثْمَانُ بْنُ أَبِي شَيْبَةَ، - وَاللَّفْظُ لَهُ - حَدَّثَنَا جَرِيرٌ، عَنِ الأَعْمَشِ، عَنْ زَيْدِ بْنِ، وَهْبٍ عَنْ عَبْدِ اللَّهِ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ إِنَّهَا سَتَكُونُ بَعْدِي أَثَرَةٌ وَأُمُورٌ تُنْكِرُونَهَا ‏"‏ ‏.‏ قَالُوا يَا رَسُولَ اللَّهِ كَيْفَ تَأْمُرُ مَنْ أَدْرَكَ مِنَّا ذَلِكَ قَالَ ‏"‏ تُؤَدُّونَ الْحَقَّ الَّذِي عَلَيْكُمْ وَتَسْأَلُونَ اللَّهَ الَّذِي لَكُمْ ‏"‏ ‏.‏
Reference : Sahih Muslim 1843
In-book reference : Book 33, Hadith 73
USC-MSA web (English) reference : Book 20, Hadith 4545
  (deprecated numbering scheme)