An Lushan Rebellion

The An Lushan Rebellion was a 7-year rebellion against Tang rule in China launched by the Turkic general An Lushan, who founded the Great Yan dynasty in northern China. Up to 36 million people, two-thirds of the Tang population and a sixth of the world's population, were killed in what was the largest atrocity in world history.

Background
In 734 AD, Emperor Xuanzong of Tang appointed Li Linfu as Chancellor of Tang China, shifting his focus towards religion and his concubines. Li Linfu purged his political rivals during the 740s and ensured that all of the empire's generals were of non-Chinese origin, preventing his political rivals from rising in the ranks of the military. However, the Emperor's concubine persuaded him to name her cousin Yang Guozhong to a high position at court, and Yang Guozhong allied with Li Linfu's political rivals and plotted to remove his most valued military general, An Lushan, from command over 164,000 troops at Fanyang (near present-day Beijing). When Li Linfu died in 753 AD, An Lushan grew concerned over his position and his favor at court, and he plotted to usurp the Tang throne.

Start of the rebellion
After continuous escalations between An Lushan and his enemies, he left Fanyang in 755 AD with 100,000 troops and marched on Luoyang. Emperor Xuanzong was forced to recall his armies from the Central Asian frontiers in the west, hoping to gather enough forces to deal with the rebellion. The withdrawal led to the loss of the Xiyu western regions for almost a millenia. The loyal general Feng Changqing led 60,000 troops into a series of battles with the 100,000-strong rebel army near the capital, but the veteran rebel troops defeated the smaller levy forces. Feng Changqing was forced to retreat to Tong Pass, where he was joined by Gao Xianzhi, who had recently returned from his defeat at the Battle of Talas in 751 AD. An Lushan and his army then captured Luoyang and treated the Tang officials there with civility, persuading many of them to defect to him.

Formation of Yan
In early 756, An Lushan declared himself Emperor of Great Yan with Luoyang as its capital. As the main rebel army prepared to march on Tong Pass, An Lushan dispatched other armies to the northwest (thrusting towards the bend of the Yellow River) and the east (to secure the road to Fanyang). Pockets of Tang resistance began to spring up on the path from Luoyang to Fanyang, delaying An Lushan's reinforcements and his ability to attack Tong Pass. By summer of 756, An Lushan had regained control of his home territory and began the march on Chang'an. Emperor Xuanzong had Feng Changqing and Gao Xianzhi executed for failing to protect Luoyang, and he then had the army advance from the impenetrable Tong Pass to attack Luoyang, resulting in a disastrous ambush and defeat. An Lushan and his army were now able to march on Chang'an, and the Emperor and his crown prince were forced to evacuate the capital and flee to Chengdu. Along the way, he was forced to execute several of his bureaucrats whom his soldiers blamed for the defeat at Tong Pass. Xuanzong set up his base at Chengdu while his heir Suzong arrived in Lingzhou in the north in autumn 756. Suzong was then persuaded to usurp the throne from his exiled father, ending the Tang's longest and most glorious reign. Meanwhile, An Lushan entered Chang'an and massacred a large portion of the population, forcing many others to flee.

Quelling of the Rebellion
Suzong began to gather forces to him, and, in 757, he borrowed troops from the Abbasid Caliphate in the west and the Uyghur Khaganate in the north. At the same time, An Lushan was assassinated by his subordinates who were angered at his inability to conquer the Tang, and they installed his son An Qingxu as Emperor. The coup led to the weakening and implosion of the Great Yan, enabling the Tang to strike back. Suzong regained the twin capitals of Chang'an and Luoyang from the rebels, defeating the existential threat to the Tang dynasty and ending the Great Yan.

Aftermath
The death toll of the rebellion ranged from 15 to 40 million, and the Tang dynasty's withdrawal of its loyal frontier troops and generals led to the border defenses collapsing. Vietnamese armies attacked the undefended Guangzhou region and maintained control over it for half of a decade. In 763, the Tang's Tibetan rivals briefly occupied Chang'an before being forced to retreat. The Tarim Basin and northwest, its horse-rearing pastures, and its wealthy Silk Road cities were permanently lost, and the country's economy was destroyed. The country was forced to sell titles and positions to help the economy recover, and the old taxation and land system collapsed during the rebellion as old tax rolls were burned or became obsolete. The last embers of the Yan rebellion would not be extinguished for another decade, and the Tang would rule for another 150 years before it once again fragmented into the Five Dynasties and Ten Kingdoms.