Abu Hurairah reported,

The Messenger of Allah ﷺ said, "The Children of Israil were governed by their prophets. Whenever one prophet passed away, another prophet succeeded him. But there will be no prophet after me among you."They asked, "What will happen then, Messenger of Allah?"He replied, "There will be caliphs, and they will be many."They asked, "What should we do?"He said, "Fulfill the pledge of allegiance to the first one, then the next. Give them their due, for Allah عز وجل will question them about what was entrusted to them."

Ibn Majah 2871

Sahih

حدثنا أبو بكر بن أبي شيبة حدثنا عبد الله بن إدريس عن حسن بن فرات عن أبيه عن أبي حازم

عن أبي هريرة قال

قال رسول الله ﷺ إن بني إسرائيل كانت تسوسهم أنبياؤهم كلما ذهب نبي خلفه نبي وأنه ليس كائن بعدي نبي فيكم قالوا فما يكون يا رسول الله قال تكون خلفاء فيكثروا قالوا فكيف نصنع قال أوفوا ببيعة الأول فالأول أدوا الذي عليكم فسيسألهم الله عز وجل عن الذي عليهم

ابن ماجه 2871صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Jihad
Chapter
Fulfilling the pledge of allegiance
Numbering
Darussalam 2871
Ibn Majah 2871