The year 999 marks the official end of the Samanid dynasty, and the start of a twenty-year contest between the Ghaznavids and Karakhanids to gain control over the former Samanid lands. The Ghaznavids intensified the hold of Islam in Afghanistan, while the Karakhanids brought Islam to western Xinjiang.

