党項
In 840, the Kyrgyz tribe invaded from the north with a force of around 80,000 horsemen, destroying the Uyghur capital at Ordu Baliq and other cities, and killing the Uyghur Khagan, Kürebir (Hesa). The last legitimate khagan, Öge, was assassinated in 847, having spent his 6-year reign in fighting the Kyrgyz and the supporters of his rival Ormïzt, a brother of Kürebir. After the fall of the Uyghur Khaganate, the Uyghurs migrated south and established the Ganzhou Uyghur Kingdom in modern Gansu and the Kingdom of Qocho near modern Turpan. The Uyghurs in Qocho converted to Buddhism, and, according to Mahmud al-Kashgari, were "the strongest of the infidels" while the Ganzhou Uyghurs were conquered by the Tangut people in the 1030s.