安史之亂
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.