Short answer
Yamama was the hardest battle of the Ridda wars, fought in late 11 AH or early 12 AH (632 to 633 CE) in central Arabia against the false prophet Musaylima. Khalid ibn al-Walid led the Muslims to victory, but so many Quran reciters were killed that Abu Bakr had the Quran gathered into one book.
The Sunni account is that Abu Bakr sent Khalid against Musaylima of Banu Hanifa, who claimed prophethood. Musaylima was killed, and the loss of many huffaz led Umar to urge the first collection of the Quran, as recorded in Sahih al-Bukhari.
The four schools agree on this.
Explanation
Near the end of the Prophet's ﷺ life, Musaylima of the tribe of Banu Hanifa in Yamama claimed to be a prophet. After his death several tribes left Islam or refused zakat, and false prophets gained followers. Abu Bakr sent armies against them in what are called the Ridda (apostasy) wars. Musaylima's force was the largest.
Khalid ibn al-Walid commanded the Muslims. The battle was fierce, and early on the Muslims were pushed back. They regrouped, each tribe fighting under its own banner, and drove Musaylima's men into a walled garden that became known as the Garden of Death. Musaylima was killed. Wahshi, who had killed Hamza at Uhud before he became Muslim, said he threw his spear at Musaylima, hoping to make up for what he had done.
The cost was high. Many Companions died, including Zayd ibn al-Khattab, the brother of Umar, and a large number of those who knew the Quran by heart. Umar went to Abu Bakr and said that killing had been heavy among the reciters at Yamama, and he feared much of the Quran would be lost if this continued. Abu Bakr at first hesitated, then agreed, and Zayd ibn Thabit gathered the Quran from written pieces and from memory into one collection.
So Yamama ties the history of the caliphate to the history of the Quran. Read History of the Quran, Abu Bakr and Khalid ibn al-Walid.
The evidence
Quran, Surah Al-Hijr 15:9
إِنَّا نَحْنُ نَزَّلْنَا ٱلذِّكْرَ وَإِنَّا لَهُۥ لَحَٰفِظُونَ ﴿٩﴾
Indeed, it is We who sent down the Qur'an and indeed, We will be its guardian.
Allah promised to preserve the Quran; the collection after Yamama was part of that.
Sahih al-Bukhari 4986
Sahih... استحر يوم اليمامة بقراء القرآن ...
"Killing was heavy among the reciters of the Quran on the day of Yamama."
Umar's words that led to the first collection.
Sahih al-Bukhari 4072
Sahih... لأخرجن إلى مسيلمة لعلي أقتله فأكافئ به حمزة ...
"I will go out against Musaylima; perhaps I will kill him and make up for Hamza."
Wahshi's account of going out to kill Musaylima, in which he says he threw his spear at him.
Where the ruling is recorded
- al-Bidaya wa al-Nihaya (Ibn Kathir), Events of the year 11 AH, the battle of Yamama and the killing of Musaylima. The full account of the battle.
- Fath al-Bari (Ibn Hajar), Commentary on Kitab Fada'il al-Quran, chapter on the collection of the Quran. Explains Umar's request and Zayd's method.
- al-Isaba fi Tamyiz al-Sahaba (Ibn Hajar), Entry on Zayd ibn al-Khattab. Records his martyrdom at Yamama.
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.