안사의 난
The Tang dynasty became weakened considerably due to the An Lushan Rebellion, and the Tibetans took the opportunity to expand into Gansu and the Western Regions. The Tibetans took control of Turfan in 792.