The Prophet died in 632 without an arrangement that everyone accepted, and the disagreement about what should have happened next is the origin of the division between Sunni and Shia Islam. Every later dispute about religious authority in Islam refers back to it.
The Sunni account. The community chose. Abu Bakr was acclaimed at Saqifa, and Umar, Uthman and Ali followed by processes of consultation and acclamation that Sunnis regard as legitimate. The four are the Rightly Guided Caliphs, and the model they establish is that leadership of the community is a communal matter, settled by the qualified people of the community, and that the caliph is a political and executive successor with no prophetic or doctrinal function.
The Shia account. The Prophet designated Ali, most explicitly at Ghadir Khumm, and the community disregarded it. On this reading the first three caliphs were usurpers, and authority belonged by designation to Ali and after him to his descendants, who are Imams, not merely rulers, and whose authority is religious in a way no election could produce.
The two accounts cannot both be right and neither side has moved. What follows from them, though, is the more interesting difference: who gets to say what the religion requires. The Sunni answer distributes it, to the scholars, the schools of law, the consensus of the community, with the caliph enforcing rather than defining. The Shia answer concentrates it in the Imam and, in his absence, in the jurists who represent him.
The caliphate itself ran through the Umayyads, the Abbasids and eventually the Ottoman claim, and was abolished by the Turkish Grand National Assembly in March 1924. Restoration movements have followed ever since. The declaration of a caliphate by the Islamic State in 2014 was rejected by the overwhelming weight of Muslim scholarly opinion, on grounds including that the classical qualifications were absent and that the consent of the community, which every account of the office requires in some form, had not been sought and would not have been given.