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

It has been narrated by Abu Huraira that the Prophet (may pceace be upon him) said:

Banu Isra'il were ruled over by the Prophets. When one Prophet died, another succeeded him; but after me there is no prophet and there will be caliphs and they will be quite large in number. His Companions said: What do you order us to do (in case we come to have more than one Caliph)? He said: The one to whom allegiance is sworn first has a supremacy over the others. Concede to them their due rights (i. e. obey them). God (Himself) will question them about the subjects whom He had entrusted to them.
حَدَّثَنَا مُحَمَّدُ بْنُ بَشَّارٍ، حَدَّثَنَا مُحَمَّدُ بْنُ جَعْفَرٍ، حَدَّثَنَا شُعْبَةُ، عَنْ فُرَاتٍ الْقَزَّازِ، عَنْ أَبِي حَازِمٍ، قَالَ قَاعَدْتُ أَبَا هُرَيْرَةَ خَمْسَ سِنِينَ فَسَمِعْتُهُ يُحَدِّثُ، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏"‏ كَانَتْ بَنُو إِسْرَائِيلَ تَسُوسُهُمُ الأَنْبِيَاءُ كُلَّمَا هَلَكَ نَبِيٌّ خَلَفَهُ نَبِيٌّ وَإِنَّهُ لاَ نَبِيَّ بَعْدِي وَسَتَكُونُ خُلَفَاءُ فَتَكْثُرُ ‏"‏ ‏.‏ قَالُوا فَمَا تَأْمُرُنَا قَالَ ‏"‏ فُوا بِبَيْعَةِ الأَوَّلِ فَالأَوَّلِ وَأَعْطُوهُمْ حَقَّهُمْ فَإِنَّ اللَّهَ سَائِلُهُمْ عَمَّا اسْتَرْعَاهُمْ ‏"‏ ‏.‏
Reference : Sahih Muslim 1842 a
In-book reference : Book 33, Hadith 71
USC-MSA web (English) reference : Book 20, Hadith 4543
  (deprecated numbering scheme)