The Prophet ﷺ said, "The Children of Israil were governed by the prophets. Whenever one prophet died, another prophet succeeded him. But there will be no prophet after me. There will be caliphs, and they will be many."The companions asked, "What do you command us to do?"He replied, "Fulfill your pledge of allegiance to the first one, then the next, and give them their due, for Allah will question them about what He entrusted to their care."
عن النبي ﷺ قال: كانت بنو إسرائيل تسوسهم الأنبياء كلما هلك نبي خلفه نبي، وإنه لا نبي بعدي، وسيكون خلفاء فيكثرون قالوا: فما تأمرنا؟ قال: فوا ببيعة الأول فالأول، أعطوهم حقهم، فإن الله سائلهم عما استرعاهم.
Bukhari narrated it in the Book of the Prophets (3455), and Muslim narrated it in the Book of Leadership (1842/44), both from Muhammad bin Bashshar, who said, "Muhammad bin Jafar narrated to us, he said, Shubah narrated to us, from Furat al-Qazzaz, who said, 'I heard Abu Hazim say, "I sat with Abu Hurairah for five years and heard him narrate," and he then mentioned it.'"His statement, "There will be caliphs, and they will multiply," is one of the signs of prophethood. It came to pass just as the Prophet ﷺ had foretold, and it was found to be so at different times. Among these was the people's pledge of allegiance to Ibn Zubayr in Makkah, to Marwan in Syria, to Banu Abbas in Iraq, to Banu Marwan in Andalusia, to Banu Ubayd in Egypt, and then to Banu Abdul-Mumin in the Maghreb.His statement, "Fulfill the pledge to the first one, then the next," is evidence of the obligation to fulfill the pledge given to the first caliph. In this hadith he remained silent about the ruling concerning the other claimant, but he stated it explicitly in the following hadith, where he said, "If another comes to dispute with him, strike off the neck of the other."