An Lushan Rebellion: Emperor Xuanzong flees the capital Chang'an as An Lushan's forces advance toward the city.

The An Lushan Rebellion was an uprising against the Tang dynasty of China towards the mid-point of the dynasty (from 755 to 763), with an attempt to replace it with the Yan dynasty. The rebellion was originally led by An Lushan, a general officer of the Tang military system. The event involved military activity and direct deaths from battle, but also significant associated population loss from famine, and population dislocations. The event is also known, especially in Chinese historiography, either as the An–Shi Rebellion or as the An–Shi Disturbances (simplified Chinese: 安史之乱; traditional Chinese: 安史之亂; pinyin: Ān Shǐ zhī luàn). The use of the term luàn (“chaos”) indicates the extreme social instability and population loss which eventually resulted, far beyond the initial consequences of the rebellion.

Traditionally, Chinese family names have begun with the family name first. In this case the family name of the initial rebel leader is An. The term Ān-Shǐ is used to recognize that the rebellion continued after An Lushan's death, with the leadership then transitioning to the Shi family, although at first An Lushan's son An Qingxu claimed succession. However, Shi Siming, who had been close to An Lushan, became successor, and then Shi's son Shi Chaoyi. The Tianbao Rebellion (天寶之乱) began in the 14th year of the latter's era. The rebellion's overt phase began on 16 December 755, when An Lushan mobilized his army and marched to Fanyang, and ended when his Yan dynasty fell on 17 February 763 (although the effects lasted past this). The rebellion spanned the reigns of three Tang emperors against the rival Yan dynasty before it was finally quashed. Besides the Tang dynasty loyalists, others involved were anti-Tang forces, especially those in An Lushan's base area in Hebei and Sogdian forces or influences, among others. The rebellion and subsequent disorder resulted in a major loss of life and large-scale destruction. It significantly weakened the Tang dynasty and led to the loss of the Western Regions. The Tang dynasty hired 4,000 mercenaries from Abbasid territories and the Uyghur Khaganate intervened for the Tang dynasty against An Lushan.

The Uyghur Khaganate exchanged princesses in marriage with Tang dynasty China in 756 to seal the alliance against An Lushan. The Uyghur Khagan Bayanchur Khan had his daughter Uyghur Princess Pijia (毗伽公主) married to Tang dynasty Chinese Prince Li Chengcai (李承采), Prince of Dunhuang (敦煌王), son of Li Shouli, Prince of Bin, while the Tang dynasty Chinese princess Ninguo married Uyghur Khagan Bayanchur.