After the Uyghur empire disintegrated a branch of the Uyghurs migrated to oasis settlements in the Tarim Basin and Gansu, such as Gaochang (Karakhoja) and Hami City (Kumul), and set up a confederation of decentralized Buddhist states called Kara-Khoja. Others, mainly closely related to the Uyghurs (the Karluks), occupying the western Tarim Basin, Ferghana Valley, Jungaria and parts of modern Kazakhstan bordering the Muslim Turco-Tajik Khwarazm Sultanate, converted to Islam no later than the 10th century and built a federation with Muslim institutions called Kara-Khanlik, whose princely dynasties are called Karakhanids by most historians. Its capital, Balasagun flourished as a cultural and economic centre.