Sunni and Shi'i
Sunni believes that the assent of community brings forth a khalifah who is also imam, through a process of selection and confirmation, though many tended not to emphasize the imamate as a necessary category of spiritual leadership after the Umayyad's rise to the caliphate.
Shi'i believes the Imam is not necessarily the political leader, but he is the religious leader of the community. Imam is designated by God, therefore holds unquestioned leadership but is identified in human society in different ways.
There are twelve Shi'i hereditary Imams, but none except Ali ever held political power, commanded armies or collected taxes, but they were leaders of the religious society. Shiis would use this claim as source of political legitimacy.
According to Sunni leaders, the Khalifah was the leader of political society. Every effort on the part of Sunni khalifahs to dictate what Islam was failed. Ultimately (by the 800s), the khilafah itself failed. The khilafah in its primary expression ended in 1258. From the 800s on they ruled over a shrinking realm, from the height of their power they lost power, and in the process of losing power, the concept of political authority became reified in the Arabic word for power or authority.
Sultan was an attribute of the khilafah (use: "he has sultan," or legitimate authority). It is based on the use of the term in the Qur'an with reference to the duty of believers to obey the prophet and those in authority.
By the year 1000 CE, people had taken the name Sultan itself as at title. It became an institution or office dispersing political power that was supposed to belong to the khalifah. A separation of power and authority thus took place as part of the leadership crisis of the khilafah. The ideal was that the khilafah, imamate can legitimize power of others. The reality was that the sultan wielded the power of the caliphate on behalf of the khalifah. Sultans pointedly did not take the title khalifah.
Al-Mawardi (d. 1058) - most important political theorist in Islam, wrote a famous work on the concept of sultan. He described two types of sultan, both derived from the power of the khalifah - one in which the khalifah designates sultan, and another type in which the sultan seizes power, then is hopefully recognized after the fact. In the century before the Mongols, the khilafah declined. Decline of the khilafah began before, to the point that they became mere ceremonial leaders, receiving delegations, holding processions, but not wielding real power. The Mongol invasion of Baghdad in1258 was the turning point. A member of the Abbasid family was later set up in Cairo by a sultan as the khalifah, but he was not generally recognized as legitimate, and was seen as a mere puppet.
An interesting social and religious phenomenon accompanying the decline of the khilafah after 1258 was that the hajj (pilgrimage) to Makkah began to take on much more prominence in Islamic social life. Ulama' and their donors established more religious institutions at Makkah and other prominent cities, and it became more common for people to learn and study for a time at Makkah, and they became very important places for people to stay and learn about Islam. The experience of Muslims was becoming more important than the khilafah as the center of Islam. Pilgrimage and study was an example of the re-centering of Islam. Thus controlling and facilitating access to the pilgrimage became an important source of power and legitimacy for local rulers of the Hijaz and the pilgrimage routes. A modern example is use of the title "Custodian of the Two Holy Mosques" by the Saudi monarchy as legitimizing its own actions, or drawing legitimacy from their possession, control and service to the holy places of Makkah and Madinah.
Another source of re-centering was that Islam had developed a body of law in lieu of a Church, clergy; ulama' were practitioners, a group not centralized but distributed across the Muslim world. The ulama' were defined as those who possess religious knowledge and training.