Karakhanid–Samanid wars

The Kara-Khanid Khanate and the Samanid Empire fought two wars in 990–991 and 999–1000. Satuq Buğra Khan's grandson, Hasan ibn Sulayman, attacked the Samanids in the late 10th century. Between 990 and 991, Hasan captured Sayram, Fergana, Ilaq, Samarkand and the Samanid capital, Bukhara. However, Hasan ibn Sulayman died in 992 and the Samanids returned to Bukhara.

Hasan ibn Sulayman's campaign in (990–991)
Hasan ibn Sulayman Khan invaded Samanid lands in 991 upon the invitation of disgruntled vassals and the governor of Khorasan, Abu'l-Hasan Simjuri. Then he destroyed the army sent by Nuh II and captured Sayram. After the Samanid governor of Samarkand, Fa'iq, surrendered to Hasan, he marched towards Bukhara. Nuh II escaped and the Karakhanids entered the capital in the late spring of 992. Fa'iq, the Samanid governor of Samarkand surrendered to Hasan Khan, who then marched toward Bukhara. Nuh fled, and the Karakhanids entered the capital in the late spring of 992, where they managed to capture Abu Ali Damghani, vizier of Nuh II. In the same year, Hasan ibn Sulayman minted coins in Ilaq and adopted the titles "Sahib ud-Dawla" (Owner of the State) and "Zahir al-Dawaa (Supporter of the Cause). However, Hasan ibn Sulayman died from illness in 992 and the Samanids returned to Bukhara.

Karakhanid's campaign in (999–1000)
Hasan ibn Sulayman's cousin Ali Arslan Khan (title: Kara Khan or Arslan Khan) continued the campaign against the Samanids in 999. Ali's son, Nasr Khan captured Samarkand and Bukhara. The Samanid lands were divided between the Ghaznavids, who captured Khorasan and Afghanistan, and the Karakhanids, who captured Transoxiana. All in all, the Amu Darya became the border between two rival empires.

Aftermath
The Karakhanid state was divided into regions (Ülüş system), just like the Turkic and Mongolian nomads. The Karakhanid regions were associated with four major urban centers: Balasagun in Zhetysu (then the capital of the Karakhanid state), Kashgar in Xinjiang, Uzkend in Fergana, and Samarkand in Transoxiana. The original provinces of the dynasty, Zhetysu and Kashgar, and their khans had implicit seniority over those who ruled in Transoxiana and Fergana. Each of Ali Arslan Khan's four sons (Ahmed, Nasr, Mansur, Muhammad) had their own independent territory within the Karakhanid state. Nasr, the conqueror of Transoxiana, held the large central region of Transoxiana (Samarkand and Bukhara), Fergana (Uzkend) and other regions, but after his death his territory was further divided. Ahmet retained Zhetysu and Tashkent and became the head of the dynasty after Ali's death. Brothers Ahmed and Nasr pursued different policies against the Ghaznavids in the south; while Ahmed tried to form an alliance with Mahmud of Ghazni, Nasr tried to expand into Ghaznivid territory but failed.