Uyghur Khanate
Replacing the Göktürks on the Mongolian Plateau in 744, the Uyghur Khaganate ruled the steppe until 840 from its walled capital of Karabalgasun in the Orkhon Valley. Under the Yaghlakar dynasty, Uyghur armies aided Tang China during the An Lushan rebellion, secured lucrative silk-for-horse exchanges, and saw Bögü Qaghan adopt Manichaeism around 762 through Sogdian influence before the Ediz clan took the throne in 795.
Sogdian operated across the khanate for commerce and chancery, while western garrisons at Beshbalik guarded the route north of the Tian Shan. After Yenisei Kirghiz armies sacked Karabalgasun in 840, remnants near the Tang border still acclaimed Öge and Enian as khagans through 848 while other Uyghurs migrated west to establish oasis kingdoms in Qocho and Ganzhou.