Khulafa or Caliphs are the leaders of an Islamic state or kingdom. Five Khulafa E Rashid (May Allah be pleased with them All) are the popular Khulafa of Muslims. They are known as Rightly Guided Caliphs.
The word Caliph is the English form of the Arabic word 'Khalifah' which is short for Khalifatu Rasulillah. The latter expression means Successor to the Messenger of God, the Prophet Muhammad (May Allah Honour him and Grant him Peace). The title Khalifatu Rasulillah. was first used for Abu Bakr, who was elected head of the Muslim Community after the death of the Prophet Muhammad (May Allah Honour him and Grant him Peace).
5. Hasan bin Ali (R) (661-661 C.E.)
Hasan bin ali (R) was the last Khulafa E Rashid, who ruled for 6 months.
The period of rule of the Khulafa E Rashid or Khulafa ar Rashidun was of Thirty Years.
Narrated by Safinah (R): The Prophet Muhammad (May Allah honor Him and grant Him peace) said: “The Caliphate of Prophecy will last thirty years; then Allah will give the Kingdom of His Kingdom to anyone He wills”. Sunan Abu Dawud 4629. 
The imam (ruler) or caliph or Khalifa was appointed to lead the Islamic state by one of three methods:
1. He was chosen and elected by the decision makers (ahl al-hall wa’l-‘aqd). For example, Abu Bakr As-Siddiq (R) became caliph when he was elected by the decision makers, then the Sahaabah (Companions of Prophet Muhammad (May Allah honor Him and grant Him peace)) unanimously agreed with that and swore allegiance to him, and accepted him as caliph.
‘Umar bin Al-Khattab Al-Farooq (R) became caliph in a similar manner, when ‘Umar bin Al-Khattab Al-Farooq (R) delegated the appointment of the caliph to come after him to a shoora council of six of the senior Sahaabah, who were to elect one of their number. ‘Abd al-Rahmaan ibn ‘Awf (R) consulted the Muhaajireen and Ansaar, and when he saw that the people were all inclined towards ‘Umar bin Al-Khattab Al-Farooq (R), he swore allegiance to him first, then the rest of the six swore allegiance to him, followed by the Muhaajireen and Ansaar, so he was elected as caliph by the decision makers. ‘Ali bin Abi Talib (R) became caliph in a similar manner, when he was elected by most of the decision makers.
2. Appointment to the position by the previous caliph, when one caliph passes on the position to a particular person who is to succeed him after he dies. For example, ‘Umar bin Al-Khattab Al-Farooq (R) became caliph when the position was passed on to him by Abu Bakr As-Siddiq (R)
3. By means of force and prevailing over others. When a man becomes caliph by prevailing over the people by the sword, and he establishes his authority and takes full control, then it becomes obligatory to obey him and he becomes the leader of the Muslims. Examples of that include some of the Umayyad and ‘Abbasid caliphs, and those who came after them. This method is contrary to sharee’ah, because it is seized by force. But because great interests are served by having a ruler who rules the ummah, and because a great deal of mischief may result from chaos and loss of security in the land, the one who seizes authority by means of the sword should be obeyed if he seizes power by force but he rules in accordance with the laws of Allah.
Shaykh Muhammad ibn Saalih al-‘Uthaymeen (may Allah have mercy on him) said: If a man rebels and seizes power, the people must obey him, even if he seizes power by force and without their consent, because he has seized power.
The reason for that is that if his rule is contested, it will lead to a great deal of evil, and this is what happened during the Umayyad period when some of them seized power by means of force and gained the title of caliph, and people obeyed them in obedience to the command of Allah. Sharh al-‘Aqeedah al-Safaareeniyyah (p. 688)