 The Khitan occupied Balasaghun, expelled the weak Karakhanid ruler, and founded their own state, which stretched from the Yenisei to Taraz.They then conquered Kankali and subdued Xinjiang.In 1137 near Khujand they defeated the Transoxanian Karakhanid ruler Mahmud Khan, who then appealed to their suzerain the Seljuks for help.