Islamic armies defeated the Sasanians in AD 642 at Nahavand (near modern Hamadan,
Iran) and moved on to the Afghan area, but they were unable to hold the
territory; cities submitted, only to rise in revolt, and the hastily converted
returned to their old beliefs once the armies had passed. The 9th and 10th
centuries witnessed the rise of numerous local Islamic dynasties. One of the
earliest was the Tahirids of Khorasan, whose kingdom included Balkh and Herat;
they established virtual independence from the 'Abbasid caliphate in AD 820. The
Tahirids were succeeded in 867-869 by a native dynasty from Seistan, the
Saffarids. Local princes in the north soon became feudatories of the powerful
Samanids, who ruled from Bukhara. From 872 to 999 Bukhara, Samarkand, and Balkh
enjoyed a golden age under Samanid rule.
In the middle of the 10th century a former Turkish slave named Alptegin seized
Ghazna (Ghazni). He was succeeded by another former slave, SubŁktigin, who
extended the conquests to Kabul and the Indus. His son was the great Mahmud of
Ghazna, who came to the throne in 998. Mahmud conquered the Punjab and Multan
and carried his raids into the heart of India. The hitherto obscure town of
Ghazna became a splendid city, as did the second capital at Bust (Lashkar Gah).
Mahmud's descendants continued to rule over a gradually diminishing empire until
1150, when 'Ala`-ud-Din Husayn of Ghur, a mountain-locked region in central
Afghanistan, sacked Ghazna and drove the last Ghaznavid out to India. 'Ala`-ud-Din's
nephew, Mu'izz-ud-Din Muhammad, known as Muhammad of Ghur, first invaded India
in 1175. After his death in 1206, his general, Qutb-ud-Din Aybak, became the
sultan of Delhi.
Shortly after Muhammad of Ghur's death, the Ghurid Empire fell apart, and
Afghanistan was occupied by Sultan 'Ala` ad-Din Muhammad, the Khwarezm-Shah. The
territories of the Khwarezm-Shah dynasty extended from Chinese Turkistan in the
east to the borders of Iraq in the west.