The friendly relation came to end, when Ilak Khan finding opportunity, invaded Khorasan while Sultan Mahmud was busy in the capture of
Multan in 1006 AD. Ilak Khan sent two armies: one led by his brother Chaghartigin, which captured
Balkh, and another under Subashitigin, which took
Herat. As a result, Ilak Khan gained control over the entirety of Khorasan. Sultan Mahmud receiving the news, left Multan to some of his officers, marching to Ghazni. As Mahmud advanced, Chaghartigin abandoned Balkh and fled to
Tirmidh, while Sultan Mahmūd sent Arslan Jadhib with 10,000 troops to pursue Subashitigin, who also fled upon their approach. Subashitigin attempted to reach
Bukhara but was blocked by floods in the Murghab River and excessive heat in the Ghuzz desert. Subashitigin defeated Muhassin b. Tariq, a Ghuzz tribal chief, at
Sarakhs and escaped to
Jurjan, hoping for aid from
Qabus, emir of
Ziyarid dynasty. Disappointed, he returned to Nasa, left his baggage, and headed for
Marv. The sultan dispatched Abū 'Abdu'llah Muhammad b. Ibrāhīm at-Tā'ī, an Arab commander, who surrounded and defeated Subashitigin in the desert, capturing his brother and 700 soldiers. Subashitigin managed to scaped to Bukhara. Meanwhile, Ilak Khan sent Chaghartigin with 12,000 troops to attack Balkh to divert the attention. Mahmud let him to occupy Balkh temporarily. After Subashitigin’s defeat and expulsion from Khorasan, Mahmud turned to Balkh, prompting Chaghartigin to flee to Bukhara. By mid of 1006, Khorasan was cleared of Kara-Khanid forces. == Battle of Balkh ==