the core of his army, he also hired the Afghans, especially the Ghilji tribe, in his dominion. According to al-Utbi, Sabuktigin attacked Lamghan, conquering it and burning the residences of the "infidels", while also demolishing its idol-temples and establishing Islam. He proceeded to slaughter the non-Muslims, destroyed their temples and plundered their shrines. It is said that his forces even risked frostbite on their hands while counting the large booty. To avenge the savage attack of Sabuktigin, Jayapala, who had earlier taken his envoys as hostage, decided to go to war again in revenge. According to al-Utbi, he assembled an army of 100,000 against Sabuktigin. The much later account of Ferishta states that it included troops from Kanauj, Ajmer, Delhi and Kalinjar. The two sides fought on an open battlefield in Laghman. Sabuktigin divided his army into packs of 500 who attacked the Indians in succession. After sensing that they were weakened, his forces mounted a concerted attack. The forces of Kabul Shahi were routed and those still alive were killed in the forest or drowned in the river. The second battle that took place between Sabuktigin and Jayapala in 988 AD, resulted in the former capturing territory between Lamghan and Peshawar. Al-Utbi also states that the Afghans and Khaljis, living there as nomads, took the oath of allegiance to him and were recruited into his army. He helped Nuh II in expelling the rebel and heretic Abu Ali Simjur from Khorasan, resulting in its governorship being given to Sabuktigin who appointed Mahmud as his deputy there. He also appointed Ismail as the successor to his kingdom and died in 997. A succession war erupted between Ismail and Mahmud, with the latter gaining the throne in 998. Mahmud The Samanid amir Mansur II appointed Bektuzun as Khorasan's governor after Sabuktigin's death. Mahmud however wished to reacquire the governorship after defeating his brother Ismail and his allies. Bektuzun and Fa'iq, the de facto power behind the Samanid throne, toppled Mansur II as they did not trust him, and replaced him with Abu'l Fawaris 'Abd al-Malik. Their forces were however defeated in 999 by Mahmud, who acquired all the lands south of Oxus, with even those to the north of the river submitting to him. The Samanid dynasty was later ended by the Karakhanids. In 1002, Mahmud also defeated the Saffarid Amir Khalaf ibn Ahmad and annexed Sistan. Wars against Kabul Shahi