Ibn Khaldun on the Caliphate

Appointing a leader (imam) is obligatory. Its mandatory nature is known through revelatory law (shar‘) by the consensus of the Companions and the next generation of Followers, because the Companions of the Prophet (ﷺ) hastened upon his death to pledge allegiance and submit consideration of their affairs to Abu Bakr (May God be pleased with him). And it was thus in every age thereafter, and the matter was established as consensus indicating the obligation of appointing a leader (imam).