Short answer
On the day the Prophet ﷺ died, the Ansar met at the Saqifa of Banu Sa'ida. Abu Bakr, Umar and Abu Ubayda joined them, Umar pledged allegiance to Abu Bakr, and the others followed. The next day the general pledge was given in the mosque. He ruled from 11 to 13 AH (632 to 634 CE).
Sunni Muslims hold that Abu Bakr was the rightful first caliph by the agreement of the Companions, and that the Prophet's ﷺ choice of him to lead the prayer in his last illness pointed to it. Ali and the rest of Banu Hashim also gave their pledge.
The four schools agree on this.
Explanation
When the news of the Prophet's ﷺ death spread, many could not accept it. Umar himself denied it. Abu Bakr came, uncovered his face, kissed him, then went out and said: whoever worshipped Muhammad, Muhammad has died; whoever worships Allah, Allah is Living and never dies. He recited "Muhammad is not but a messenger; messengers have passed before him" (3:144), and people said it was as if they had never heard the verse before.
Meanwhile the Ansar gathered at the Saqifa (a covered hall) of Banu Sa'ida to choose a leader. Abu Bakr, Umar and Abu Ubayda went to them. One of the Ansar suggested a leader from each side. Abu Bakr reminded them of the place of Quraysh among the Arabs. Umar then said: no, we pledge to you, for you are our master, the best of us and the most beloved of us to the Messenger of Allah. He took Abu Bakr's hand and pledged, and the people followed. The public pledge was given in the mosque the next day.
Scholars point to signs that he was meant to lead: the Prophet ﷺ ordered "Tell Abu Bakr to lead the people in prayer" in his last illness, and Abu Bakr was his companion in the cave during the Hijrah (9:40). Bukhari records that Ali gave his public pledge after the death of Fatimah, six months later, and spoke of Abu Bakr's virtue. Ibn Kathir and others cite reports that Ali had already pledged in the first days, and treat this as a renewal of it.
Abu Bakr then sent Usama's army, fought the Ridda wars and had the Quran collected. See Abu Bakr al-Siddiq, Battle of Yamama and How did Abu Bakr die?
The evidence
Quran, Surah Aal-i-Imraan 3:144
وَمَا مُحَمَّدٌ إِلَّا رَسُولٌۭ قَدْ خَلَتْ مِن قَبْلِهِ ٱلرُّسُلُ ۚ أَفَإِي۟ن مَّاتَ أَوْ قُتِلَ ٱنقَلَبْتُمْ عَلَىٰٓ أَعْقَٰبِكُمْ ۚ وَمَن يَنقَلِبْ عَلَىٰ عَقِبَيْهِ فَلَن يَضُرَّ ٱللَّهَ شَيْـًۭٔا ۗ وَسَيَجْزِى ٱللَّهُ ٱلشَّٰكِرِينَ ﴿١٤٤﴾
Muhammad is not but a messenger. [Other] messengers have passed on before him. So if he was to die or be killed, would you turn back on your heels [to unbelief]? And he who turns back on his heels will never harm Allah at all; but Allah will reward the grateful.
The verse Abu Bakr recited on the day of the Prophet's death.
Quran, Surah At-Tawba 9:40
إِلَّا تَنصُرُوهُ فَقَدْ نَصَرَهُ ٱللَّهُ إِذْ أَخْرَجَهُ ٱلَّذِينَ كَفَرُوا۟ ثَانِىَ ٱثْنَيْنِ إِذْ هُمَا فِى ٱلْغَارِ إِذْ يَقُولُ لِصَٰحِبِهِۦ لَا تَحْزَنْ إِنَّ ٱللَّهَ مَعَنَا ۖ فَأَنزَلَ ٱللَّهُ سَكِينَتَهُۥ عَلَيْهِ وَأَيَّدَهُۥ بِجُنُودٍۢ لَّمْ تَرَوْهَا وَجَعَلَ كَلِمَةَ ٱلَّذِينَ كَفَرُوا۟ ٱلسُّفْلَىٰ ۗ وَكَلِمَةُ ٱللَّهِ هِىَ ٱلْعُلْيَا ۗ وَٱللَّهُ عَزِيزٌ حَكِيمٌ ﴿٤٠﴾
If you do not aid the Prophet - Allah has already aided him when those who disbelieved had driven him out [of Makkah] as one of two, when they were in the cave and he said to his companion, "Do not grieve; indeed Allah is with us." And Allah sent down his tranquillity upon him and supported him with angels you did not see and made the word of those who disbelieved the lowest, while the word of Allah - that is the highest. And Allah is Exalted in Might and Wise.
Abu Bakr's companionship in the Hijrah.
Sahih al-Bukhari 3668
Sahih... بل نبايعك أنت فأنت سيدنا وخيرنا ...
"Rather, we pledge to you, for you are our master and the best of us."
Umar's pledge at the Saqifa.
Sahih al-Bukhari 678
Sahih... مروا أبا بكر فليصل بالناس ...
"Tell Abu Bakr to lead the people in prayer."
His appointment of Abu Bakr to lead the prayer.
Sahih al-Bukhari 4240
Sahih... ولم يكن يبايع تلك الأشهر ...
"He had not given the pledge during those months."
Ali's later public pledge to Abu Bakr.
Where the ruling is recorded
- Fath al-Bari (Ibn Hajar), Commentary on Kitab al-Hudud, chapter on stoning a woman pregnant from zina if she is married, the long sermon of Umar on the Saqifa. Gives Umar's own account of the Saqifa.
- al-Bidaya wa al-Nihaya (Ibn Kathir), Events of the year 11 AH, the pledge to Abu Bakr. Gathers the reports of the Saqifa and the public pledge.
- al-Aqida al-Tahawiyya, Section on the caliphate after the Prophet. States the Sunni belief that the caliphate went first to Abu Bakr, then Umar, Uthman and Ali.
This answer is pending review by the scholars on our team. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.