In 744 the Uyghur chieftain Qutlugh Bilge Köl, joining with Tang forces, destroyed the Second Turkic Khaganate and founded the Uyghur Khaganate, seating his court at Ordu-Baliq in the Orkhon valley. In 788 the khagan asked to rename his people 'Huihu' (Uyghur), 'wheeling swift as the falcon'. The khaganate kept investiture ties and silk-for-horse trade with Tang; during the An Lushan rebellion Prince Yabghu led troops that helped Tang recover its two capitals. Manichaeism entered the steppe under Uyghur patronage and became the state religion. The ninth century brought endless internal strife, until in 840 a hundred thousand Kirguz horsemen stormed the khagan's city; the khaganate collapsed and the people split into three westward migrations - one to the Hexi corridor (the Ganzhou Uyghurs), one to the Turfan oasis (the Qocho Uyghurs, a principal ancestry of the modern Uyghurs), one to the Karluk lands - transforming the ethnic map of Central Asia.
Editorial note on dating Succeeded the Turks as steppe hegemon and helped the Tang suppress the An Lushan rebellion; collapsed under the Kirghiz in 840, the tribes fleeing west.