After the fall of the Uyghur state to the Kyrgyz (840), the Karakhanid dynasty emerged in the Kashgar-Balasagun region
When the Uyghur state at Otuken was overthrown in 840, the Yaghma (who, according to Pritsak, were the founders of the dynasty) migrated westward, reached the region of Kashgar and took some places from the Karluks, and then spread into the valleys of the Chu and Ili; together with Kashgar, Balasagun became an important centre.
Sources
- TDV İslâm Ansiklopedisi, KARAHANLILAR maddesi, https://islamansiklopedisi.org.tr/karahanlilar : «840 yılına kadar Uygurlar’ı metbû tanımayı sürdürdüler ... 840’ta Uygur Devleti yıkılınca»