Muslim conquests of Afghanistan
The Muslim conquests of Afghanistan began during the Muslim conquest of Persia as the Arab Muslims migrated eastwards to Khorasan, Sistan and Transoxiana. 15 years after the Battle of Nahāvand, they controlled all Sasanian domains except parts of Afghanistan and Makran. Fuller Islamization wasn't achieved until the period between 10th and 12th centuries under Ghaznavid and Ghurid dynasty's rule who patronized Muslim religious institutions.

Khorasan and Sistan, where Zoroastrianism was well-established, were conquered, but Qandahar remained unconquered. The Arabs had begun to move towards the lands east of Persia and in 652 they captured the city of Herat, establishing an Arab governor there. The Muslim frontier in modern Afghanistan had become stabilized after the first century of Hijri calendar as the relative importance of the Afghan areas diminished. From historical evidence, it appears Tokharistan was the only area heavily colonized by Arabs where Buddhism flourished. Balkh's final conquest was undertaken by Qutayba ibn Muslim in 705. Hui'Chao, who visited around 726, mentions that the Arabs ruled it and all the inhabitants were Buddhists.

The eastern regions of Afghanistan were considered politically as parts of India. Buddhism and Hinduism held sway over the region until the Muslim conquest. Kabul and Zabulistan which housed Buddhism and other Indian religions, offered stiff resistance to the Muslim advance for two centuries, with the Kabul Shahi and Zunbils remaining unconquered until the Saffarid and Ghaznavid conquests. The significance of the realm of Zun and its rulers Zunbils had laid in them blocking the path of Arabs in invading the Indus Valley.

The Caliph Al-Ma'mun (r. 813–833 A.D.) was paid double the tribute by the Rutbil. His were the last Arab expeditions on Kabul and Zabul. The king of Kabul was captured by him and converted to Islam. The last Zunbil was killed by Ya'qub bin al-Layth along with his former overlord Salih b. al-Nadr in 865 while Zabulistan's people were converted by him. Meanwhile, the Hindu Shahi of Kabul were defeated under Mahmud of Ghazni. Indian soldiers were a part of the Ghaznavid army, Baihaki mentioned Hindu officers employed by Ma'sud. The 14th-century scholar Muslim scholar Ibn Battuta described the Hindu Kush as meaning "slayer of Indians", because large numbers of slaves brought from India died from its treacherous weather.

The geographer Ya'qubi states that the rulers of Bamiyan, called the Sher, converted in the late 8th century. Ya'qub is recorded as having plundered its pagan idols in 870 while a much later historian Shabankara'i claims that Alp-Tegin obtained conversion of its ruler in 962. No permanent Arab control was established in Ghur and it became Islamised after Ghaznavid raids. By the time of Bahram-Shah, Ghur was converted and politically united.

In the late 15th century, Babur, the founder of the Mughal Empire, arrived from Fergana and captured Kabul from the Arghun dynasty.  Between the 16th and 18th centuries, Emperor Shah Jahan and Aurangzeb ruled parts of the eastern territory.

The Afghan habitat during their conquest by Mahmud was located in the Sulaiman Mountains in the South of Afghanistan. They were enlisted by both Sabuktigin and Mahmud according to Tarikh-i-Yamini. Prior to Pashtun migration to the Kabul River valley, Tajiks formed the dominant population of Kabul, Nangarhar, Logar valley and Laghman in east Afghanistan. The Pashtuns later began migrating westward from Sulaiman mountains in the South, and displaced or subjugated the indigenous populations such as Tajiks, Hazaras, the Farsiwanis, before or during 16th and 17th centuries. The successive wave of Pashtun immigration displaced the original Kafir and Pashayi people from Kunar Valley and Laghman valley, the two eastern provinces near Jalalabad, to the less fertile mountains.

Before their conversion, the Kafir people of Kafiristan practiced a form of ancient Hinduism infused with locally developed accretions. Previously the region from Nooristan to Kashmir was called Peristan and was host to a vast number of "Kafir" cultures. They were called Kafirs due to their enduring paganism, remaining politically independent until being conquered and forcibly converted by Afghan Amir Abdul Rahman Khan in 1895–1896 while others also converted to avoid paying jizya.

Arab conquests

During the Muslim conquest of Persia, the Arabs were drawn eastwards from the Iraqi plains to central and eastern Persia, then to Media, into Khorasan, Sistan and Transoxania. 15 years after the Battle of Nahāvand, the Arabs controlled all Sasanian domain except the parts of Afghanistan and Makran. Nancy Dupree states that advancing Arabs carrying the religion of Islam easily took over Herat and Sistan, but the other areas often revolted and converted back to their old faiths whenever the Arab armies withdrew. The harshness of the Arab rule caused the native dynasties to revolt after the Arab power weakened like the Saffarids founded by the zealous Yaqub who conquered many cities of the region.

Mediaeval Islamic scholars divided modern-day Afghanistan into two regions - the provinces of Khorasan and Sistan. Khorasan was the eastern satrapy of Sasanian Empire, containing Balkh and Herat. Sistan included a number of Afghan cities and regions including Ghazna, Zarang, Bost, Qandahar (also called al-Rukhkhaj or Zamindawar), Kabul, Kabulistan and Zabulistan.

Before Muslim rule, the regions of Balkh (Bactria or Tokharistan), Herat and Sistan were under Sasanian rule. Further south in Balkh region, in Bamiyan, indication of Sasanian authority diminishes, with a local dynasty seeming ruling from the late antiquity, probably Hepthalites subject to the Yabgu of Western Turks. While Herat was controlled by Sasanians, its hinterlands were controlled by northern Hepthalites who continued to rule the Ghurid mountains and river valleys well into the Islamic era. Sistan was under Arabs but Qandahar remained out of Arab rule. Kabul and Zabulistan, housed Indic religions with the Zunbils and Kabul Shahis offering stiff resistance to Muslim rule for two centuries until Saffarid and Ghaznavid conquests.

In Afghanistan, the frontier of the Islamic conquest had become more or less stationary by the end of the first century of Hijri calendar. One reason was the relative importance of Sistan and Baluchistan had begun to diminish by the time of Mu'awiyah I, when the conquests of Bactria and Transoxania were undertaken. In addition, the conquest in the eastern direction were extended to Makran and Sind, with Muslim colonies becoming established there in 711-12.

Sistan

The earlier Arabs called Sistan as Sijistan, from the Persian Sagestan. It is a lowland region, lying round and eastwards from the Zarah lake, which includes deltas of Helmand and other rivers which drain into it. Muslim conquest of Sistan began in 23 A.H. (643-644 A.D.) when Asim bin Amr and Abdallah ibn Amir invaded the region and besieged Zaranj. The Sistanis concluded a treaty with Muslims, mandating them to pay the kharaj.

The cash-strapped Sasanian king Yazdegerd III who had a large retinue, had fled to Kerman in 650. He had to flee from Kerman to Sistan after his arrogance angered the marzban of the place, eluding an Arab force from Basra which defeated and killed the marzban. Yazdegerd lost the support of governor of Sistan after demanding taxes from him and had to leave for Merv. It is not known whether this governor was a Sasanian prince or a local ruler at that time. The Arabs had campaigned in Sistan a few years earlier and Abdallah b. Amir had now gone in pursuit of Yazdegerd. He arrived in Kirman in 651 and sent a force under Rabi ibn Ziyad al-Harithi to Sistan.

Rabi crossed the desert between Kirman and Sistan, reaching the fortress of Zilaq which was within five farsangs of the Sistan frontier. The fort was surrendered by its dihqan. The fortress of Karkuya, whose fire temple is mentioned in the anonymously authored Tarikh-e-Sistan, along with Haysun and Nashrudh, surrendered to Rabi. Rabi then encamped in Zaliq and projected the seizure of Zarang, which though had earlier submitted to Arabs, needed to be subdued again. Although its marzaban Aparviz put up a strong resistance, he was forced to surrender.

The Zaranj forces had received heavy casualties during the battle with Arab forces and were driven back to the city. According to sources, when Aparviz appeared before Rabi to discuss the terms, he found the Arab general was sitting on a chair made out of two dead soldiers and his entourage had been instructed to make seats and bolsters in the same fashion. Aparviz was terrified into submission and wished to spare his people of this fate. A peace treaty was concluded with payments of heavy dues. The treaty mandated one million dirhams as annual tribute, in addition to a 1,000 slave boys bearing 1,000 gold vessels. The city was garrisoned by Rabi.

Rabi thus succeeded in gaining Zarang with considerable difficulty and remained at the place for several years. Two years later, the people of Zarang rebelled and expelled Rabi's lieutenant and garrison. Abdallah b. Amir sent 'Abd ar-Rahman b. Samura to take back the city, who also added Bust and Zabul to Arab gains. 'Abd ar-Rahman besieged Zaranj and after the marzban surrendered, the tribute was doubled. The tribute imposed on Zarang was 2 million dirhams and 2,000 slaves.

During the period of the first civil war in the Arab caliphate (656-661), rebels in Zarang imprisoned their governor while Arab bandits started raiding remote towns in Sistan to enslave people. They gave in to the new governor Rib'i, who took control of the city and restored law and order. 'Abdallah b. Amir was made the governor of Basra and its eastern dependencies again from 661 to 664. Samura was sent back to Sistan in 661. An expedition to Khorasan was sent under Samura, a Qurayshite, that included reputed leaders like 'Umar b. 'Ubaydillah b. Ma'mar, 'Abdullah b. Khazim, Qatariyy b. al-Fuja'a and Al-Muhallab ibn Abi Sufra. He reconquered Zarang, attacked Zabulistan's ruler Zunbil and entered Kabul after a brief siege.

Ziyad ibn Abihi was appointed governor of Basra in 664 and was also made governor of Kufa and its dependencies in 670, making him the viceroy of the entire eastern half of the Islamic empire. He sent his kinsman Ubaydallah b. Abi Bakra to destroy the Zoroastrian fire temples in Fars and Sistan, confiscate their property and kill their priests. While the fire temple of Kariyan was destroyed, the one at Karkuya survived along with its herbad. Ziyad's son Abbad was appointed governor of Sijistan by Mu'awiya I in 673 and served until 681. During the course of his governorship, the province apparently remained stable and Abbad led an eastward expedition which brought Kandahar to the caliphate. Caliph Yazid I replaced Abbad with his brother Salm, who was already governor of Khurasan.

Khorasan

There is general agreement among Arabic sources that Khorasan's conquest began in the reign of Uthman under Abdallah b. Amir who had been appointed the governor of Basra (r. 649-655). Sayf's tradition however disagrees with this, dating it to 639 under the reign of Umar with Ahnaf ibn Qais leading the expedition. Al-Tabari meanwhile relates that Ahnaf's conquests occurred in 643. This could be because of confusion of Ahnaf's later activities under Ibn Amir and an attempt to magnify his role in Khorasan's conquest.

The conquest of southern Persia was completed by 23 A.H. with Khorasan remaining the only region remaining unconquered. Since the Muslims didn't want any Persian land to remain under Persian rule, Umar ordered Ahnaf b. Qais to march upon it. After capturing towns of Tabas and Tun, he attacked the region's easternmost city Herat. The Persians put up stiff resistance but were defeated and surrendered. A garrison was deployed in the city, while a column was detached which subjugated Nishapur and Tus. Umar had despatched Ahnaf with 12,000 men from Kufa and Basra after Yazdegerd who had fled to Merv. After the Arabs arrived there, Yazdegerd fled to Marw al-Rudh from where he sent ambassadors to the Khakan of the Turks, the ruler of Soghd and the Chinese emperor, asking for their assistance. Yazdegerd later fled to Balkh, where he was defeated by the Arabs and fled across Oxus River.

Umar forbade Ahnaf from crossing the river as the land beyond it was unknown to Arabs and was very far for them. Yazdegerd proceeded to Soghd whose ruler supplied him a large army. The Khaqan of Turks after assembling the troops from Ferghana, crossed the Oxus along with Yazdegerd and marched to Balkh. Ribi' b. Amir meanwhile retired with Kufan troops to Marw al-Rudh where he joined al-Ahnaf. The Sasanian king and the Khakan leading an army of 50,000 cavalry composed of men from Soghd, Turkestan, Balkh and Tokharistan, arrived at Marw al-Rudh. Ahnaf had an army of 20,000 men. The two sides fought each other from morning till evening for two months at a place called Deir al-Ahnaf.

The fighting at Deir al-Ahnaf went on until Ahnaf, after being informed of a Turkic chief inspecting the outposts, went there during a particular night and successively killed three Turkic chiefs during their inspection. After learning of their deaths, the Khakan became afflicted by it and withdrew to Balkh, then he withdrew across the river to Turkestan. Yazdegerd meanwhile left from Marw al-Rudh to Merv, from where he took his empire's wealth and proceeded to Balkh to join the Khakan. He told his officials he wanted to hand himself to the protection of the Turks, but they advised him against it and asked him to seek protection from the Arabs which he refused. He left for Turkestan while his officials took away his treasures and gave them to Ahnaf, submitting to the Arabs and were allowed to go back to their respective homes.

Abdullah b. Amir went to Khorasan from Kerman in 650 and sent out along with a vanguard of Tamimi Arabs and 1,000 asawira via Quhistan. The people of Tabasayn had broken their peace treaty and had allied with the Hepthalites of Herat. al-Ahnaf reconquered Quhistan and defeated Herat's Hepthalites at Nishapur. The kanarang or marzaban of Tus asked the Arabs for assistance against the raiding Hepthalites of Herat and Badghis. He agreed to a peace agreement for 600,000 dinars.

The Hepthalite action prompted the Muslims undertaking military operation to secure their positions in Khorasan. After fall of Tus, Ibn Amir sent out an army against Herat. The ruler (marzaban or azim) of the place agreed to a peace treaty for Herat, Badghis and Pushang for a tribute of 1 million dirhams. The ruler who was known as azim or the "mighty one" in Futuh al-Buldan, may have been a Hepthalite chief. The Rightly Guided Caliphs followed the earlier rule of Muhammad of imposing jizya on several bodies jointly and in some cases also imposed the condition they host Muslims. This rule was followed in most Iranian towns, with the jizya not specified on per capita basis, but was left to the local rulers though some Muslim commanders stressed the amount on the ability of the ruler to pay. The same wording can be seen in Ibn Amir's treaty.

In 652, Ibn Amir sent al-Ahnaf to invade Tokharistan with 4,000 Arabs and 1,000 Iranian Muslims (evidently the Tamimis and asawira), probably because of assistance of its ruler to Yazdegerd's son Peroz. While Marw al-Rudh's garrison agreed to a peace term for the entire district under 300,000 dirhams, the town itself remained besieged. The last major stronghold of Sasanians, Marw al-Rudh, fell to him after a fierce battle. After bloody fighting, its marzaban agreed to a peace treaty for 60,000 or 600,000 dirhams as well as a mutual defence pact. He was also allowed to keep his ancestral lands, for the office of marzaban to be hereditary in his family and to be exempt from taxes along with his whole family. Baladhuri quotes Abu Ubayda as stating that the Turks were supporting the inhabitants of the town. These Turks were Hepthalites, probably from Guzgan which may explain the reason behind Arabs next attacking Guzgan, Faryab and Talqan.

Al-Mada'ini specifically states that Ahnaf while leading the next expedition, didn't want to ask for assistance from the non-Muslims of Marw al-Rudh, probably as he didn't trust them. The Arabs camped at Qasr al-Ahnaf, a day's march to north of Marw al-Rudh. The 30,000-strong army comprising troops of Guzgan, Faryab and Talqan, supported by the Chaghanian troops, advanced to meet them. The battle was inconclusive, but the opposing side dispersed with some remaining at Guzgan while Arabs withdrew to Marw al-Rudh. Ahnaf sent an expedition, led by al-Aqra' b. Habis and apparently consisting exclusively of Tamims, to Guzgan. The Arabs defeated Guzgan and entered it by force. Ahnaf meanwhile advanced towards Balkh, making peace treaties with Faryab and Taloqan along the way.

The permanent pacification of Khorasan was a protracted affair with the local potentates often rebelling and appealing to outside powers like the Hepthalites, Western Turks or Turgesh, Sogdians and the imperial Chinese who claimed a degree of suzerainty over Central Asia, for help. Within a year after Yazdegerd's death, a local Iranian notable named Qarin started a revolt against the Arabs in Quhistan. He gathered his supporters from Tabasayn, Herat and Badghis, assembling a reported army of 40,000 insurgents against Arabs in Khorasan. The Arabs made a surprise attack however, killing him and many of his people while many others were taken captive. It was expected that the recently subjugated people would revolt. However, in Khorasan, no all-out effort seems to have been undertaken to the expel the Arabs after Qarin's rebellion. Chinese sources state that there was an attempt to restore Peroz by Tokharistan's army, however this episode is not confirmed by Arab sources.

Peroz had settled among the Turks, took a local wife and had received troops from king of Tokharistan. In 661, he established himself as king of Po-szu (Persia) with Chinese help in a place the Chinese called Ja-ling (Chi-ling), which is assumed to be Zarang. His campaigns are reflected in Muslim sources, which mention revolts in Zarang, Balkh, Badghis, Herat, Bushanj and also in Khorasan during the First Fitna period in reigns of Ali and Muawiyah. Though they don't mention Peroz, they do state that Ali's newly appointed governor of Khorasan had heard in Nishapur that governors of the Sasanian king had come back from Kabul and Khorasan had rebelled. However, the region was reconquered under Muawiyah. Piroz went back to Tang Empire's capital and was given a grandiose title as well as permission to build a fire temple in 677.

Yazid ibn al-Muhallab succeeded his father as governor of Khorasan in 702 and campaigned in Central Asia, but achieved little success apart from Nezak Tarkhan's submission at Badghis.

Tokharistan

Tokharistan, roughly ancient Bactria, is today divided between Afghanistan, Tajikistan and Uzbekistan. According to the most general usage of the name, Tokharistan is the wide valley around the upper Oxus river surrounded by mountains on three sides before the river moves into open plains. The major city was Balkh, one of the greatest urban centers of northeastern Iran. It was located upon crossroads and conduits of trade in many directions, enabling control of these routes if it was conquered. During the governorship of Abu 'l Abbas 'Abdallah b. Tahir (r. 828–845), a list of districts (kuwar) of the region exists, including as far as Saghaniyan in the north and Kabul in the south. Other places listed are Tirmidh, Juzjan, Bamiyan, Rūb and Samanjan. Some Arab geographers used the name only for southern part of Oxus valley.

Balkh was also a part of Khorasan along with other areas through varying extensions of time. Per al-Tabari, Yazdegerd fled from Marw-al Rudh to Balkh during Ahnaf's conquest of Khorasan in 643. He fortified himself but was defeated by the Arabs and fled across the Oxus River. Yazdegerd proceeded to Soghd whose ruler supplied him a large army. The Khaqan of Turks after assembling the troops from Ferghana, crossed the Oxus along with Yazdegerd and marched to Balkh.

In 652, Ibn Amir sent al-Ahnaf to invade Tokharistan with 4,000 Arabs and 1,000 Iranian Muslims (evidently the Tamimis and asawira), probably because of assistance of its ruler to Yazdegerd's son Peroz. He approached Balkh after conquering Marw al-Rudh and fighting an inconclusive battle with a 30,000-strong force from Guzgan, Faryab and Talqan. After arriving at Balkh, he besieged the city, with its inhabitants offering a tribute of 400,000 or 700,000 dirhams. He deputed his cousin to collect the tribute and advanced to Khwarezm but returned to Balkh as winter approached. It was in Balkh in fall of 652 when the local people introduced his cousin Asid to gifting gold and silver to their governor during Mihrijan.

Ziyad b. Abi Sufyan reorganised Basra and Kufa, excluding many from the diwan and inspiring him to settle 50,000 families in Khorasan. Both Baladhuri and Mad'aini agree upon the number, though the latter states each half were from Basra and Kufa. Al-'Ali disagrees, stating the Kufans were 10,000. Ghalib had been unsuccessful in his expedition, and Rabi b. Ziyad al-Harithi who was appointed governor of Khorasan in 671 led the settlement expedition. He advanced to Balkh and made a peace treaty with the locals who had revolted after al-Ahnaf's earlier treaty.

Qutayba ibn Muslim led the final conquest of Balkh. He was tasked with subduing the revolt in Lower Tokharistan. His army was assembled in spring of 705 and marched through Marw al-Rudh and Talqan to Balkh. Per one version in Tarikh al-Tabari, the city was surrendered peacefully. Another version, probably to promote a Bahilite claim on the Barmakids, speaks of a revolt among the residents. The latter may be the correct version as Tabari describes the city as ruined four years later. The wife of Barmak, a physician of Balkh, was taken captive during the war and given to 'Abdullah, Qutayba's brother. She was later restored to her lawful husband after spending a period in 'Abdullah's harem. Khalid was thus born in 706 and Abdallah accepted the implications of paternity without disturbing Barmak's conventional responsibilities or affecting Khalid's upbringing.

In 708-709, the Ispahbadh who was a local ruler, received a letter from the Hepthalite rebel Nizak Tarkhan who was trying to unite the aristocracy of Tokharistan against Qutayba. The Arabs built a new military encampment called Baruqan two farsangs away from the city. In 725, the governor Asad ibn Abdallah al-Qasri had the city restored after a feud among Arab troops with Barmak being employed as his agent for the task.

Early Arabs tended to treat Iran as a single cultural unit, however it was a land of many countries with distinct populations and cultures. From historical evidence, it appears Tokharistan was the only area heavily colonized by Arabs where Buddhism flourished and the only area incorporated into the Arab empire where Sanskrit studies were pursued up to the conquest. The grandson of Barmak was the vizier of the empire and took personal interest in Sanskrit works and Indian religions. The eighth-century Korean traveller Hui'Chao records Hinayanists in Balkh under Arab rule. He visited the area around 726, mentioning that the true king of Balkh was still alive and in exile. He also describes all the inhabitants of the regions as Buddhists under Arab rule. Other sources indicate however that the Bactrians practiced many different religions.

Among Balkh's Buddhist monasteries, the largest was Nava Vihara, later Persianized to Naw Bahara after the Islamic conquest of Balkh. It is not known how long it continued to serve as a place of worship after the conquest. Accounts of early Arabs offer contradictory narratives. Per al-Baladhuri, its stupa-vihara complex was destroyed under Muawiyah in 650s. Tabari while reporting about the expedition in 650s, does not mention any tension around the temple, stating Balkh was conquered by Rabi peacefully. He also states that Nizak went to pray at the site during his revolt against Qutayba in 709, implying it may not have been destroyed. Also the tenth-century geographical treatise Hudud al-'Alam describes remaining royal buildings and Naw Bahara's decorations including painted image and wonderful works, probably secco or fresco murals and carvings on the temple's walls that survived into the author's time.

Sanskrit, Greek, Latin and Chinese sources from the 2nd century BCE to the 7th century CE, identify a people called "Tukharas", in the country later called Tukharistan. Badakhshan was earlier the seat of the Tukharas. There is no precise date for the Arab conquest of Badakhshan nor any record of how Islam was introduced there. Al-Tabari too mentions this region only once. In 736, Asad ibn Abdallah al-Qasri sent an expedition into Upper Tokharistan and Badakhshan against the rebel Al-Harith ibn Surayj who had occupied the fortress of Tabushkhan. Juday' b. 'Ali al-Kirmani who was sent on the expedition against al-Harith, captured Tabushkhan. Juday also had its captive defenders killed while its women and children were enslaved and sold in Balkh despite being of Arab origin. al-Harith later allied with the Turgesh and continued his rebellion until being pardoned by Caliph Yazid b. Walid in 744.

Taking advantage of the factional fighting among the Arabs, Transoxania started rebelling and Asad b. 'Abdallah in response attacked Khuttal in 737. Armed forces of Soghd, Chach and many Turks, led by the Turkish Khagan Sulu, arrived to assist them. Asad fled leaving behind the baggage of plunder from Khuttal. When Asad returned with the main body of his troops, the Turks retired to Tokharistan and he returned to Balkh. In December 737, the Turgesh attacked Khulm but were repelled by Arabs. Bypassing Balkh, they captured Guzgan's capital and sent out raiding parties. Asad mounted a surprise attack on the Turks at Kharistan who only had 4,000 troops. The Turgesh suffered a devastating defeat and lost almost whole of their army. Sulu and al-Harith fled to the territory of Tokharistan's Yabghu, with Sulu returning to his territory in winter of 737-738.

The Zunbils

The Zunbils in the pre-Saffarid period ruled in Zabulistan and Zamindawar, stretching between Ghazna and Bost, and had acted as a barrier against Muslim expansion for a long time. Zamindawar is known to have a shrine dedicated to the god Zun. It has been linked with the Hindu god Aditya at Multan, pre-Buddhist religious and kingship practices of Tibet as well as Shaivism. The followers of the Zunbils were called Turks by the Arabic sources, however they applied the name to all their enemies in eastern fringes of Iran. They are described as having Turkish troops in their service by sources like Tabari and Tarikh-e-Sistan.

The kingdom of Zabulistan (ar-Rukhkhaj) with its capital at Ghazna, where the king Zunbil or Rutbil resided, is mentioned by Chinese sources under the suzerainty of Jabghu of Turkestan. The significance for Arabs of the realm of Zun and its rulers was them preventing their campaigns from invading the Indus Valley through eastern and southern Afghanistan. It was only under the early Saffarids that mass-Islamization and conquests of the region took place unlike the plunder-raids or tribute levies of Arabs. The expeditions under Caliph al-Ma'mun against Kabul and Zabul were the last ones and the long conflict ended with the dissolution of the Arab empire following soon thereafter.

Sakawand in Zabulistan was a major centre of Hindu pilgrimage.

7th century

After appearing at Zarang, 'Abd ar-Rahman b. Samura and his force of 6,000 Arabs penetrated to the shrine of Zun in 653-654. He broke off a hand from the idol of Zun and plucked out the rubies used as its eyes to demonstrate to the marzban of Sistan that the idol could neither hurt nor benefit anyone. He also took Zabul by treaty by 656. Per Baldhuri, after being reappointed to Sistan under Muawiyah, Samura defeated Zabulistan whose people had broken the earlier agreement.

Samura was replaced by Rabi b. Ziyad and died in 50 A.H. (670 A.D.), after which the king of Zabul rebelled and conquered Zabulistan and Rukhkhaj. Ar-Rabi, the Arab governor, attacked him at Bust and made him flee. He then pursued him to Rukhkhaj where he attacked him and then subdued the city of ad-Dawar. Ziyad b. Abi Sufyan was appointed governor of Basra in 665, with Khorasan and Sistan coming under his mandate as well. He had first appointed Rabi to Sistan but replaced him later with 'Ubaydallah b. Abi Bakra. During this period, Zunbil's fierce resistance continued until he finally agreed to pay one million dirhams per Baladhuri and Tarikh-e-Sistan.

Al-Baladhuri records that under Muawiyah, Sistan's governor 'Abbad b. Ziyad b. Abihi raided and captured the city of Qandahar after bitter fighting. He also mentions the characteristic high caps of the people of the city. Though his text is somewhat ambiguous, it seems that 'Abbad had renamed the town as Abbadiya after himself. The Muslim rule was probably toppled and the name is never heard after his governorship ended in 680-1, by 698 there was no Muslim-controlled region east of Bost. The city was ruled by Arab Muslims and Zunbils, and then later Saffarids and Ghaznavids. It is infrequently mentioned in the early Islamic sources.

In 681, Salm b Ziyad was appointed the governor of Khorasan and Sistan by Yazid I. He appointed his brother Yazid b. Ziyad, apparently to lead a military expedition against the Zunbil of Zabulistan. The expedition however was disastrous, with Yazid being killed, his brother Abu-'Ubayda captured, while Arabs received heavy casualties. Salm sent an expedition by Talha b. 'Abdillah al-Khuzai to rescue his brother and pacify the region. The Arab captives were ransomed for half million dirhams and the region was pacified more through diplomacy than force.

After Talha's death in 683–684, a virtual anarchy was unleashed amongst Sistan's Arabs. His army refused allegiance to Yazid or Muawiyah II and his son 'Abadallah had to abandon Zarang, which was left without any incharge. Many Arabs took over various quarters of Zarang and areas of Sistan. This prompted Zunbil and his allies who had already inflicted a humiliating defeat on the Arabs earlier, to intervene in the Arab affairs at Sistan and Bust. Baladhuri says of this period:

During the Second Fitna period, the Zunbil attacked Sistan in 685 but was defeated and killed by the Arabs.

Abdalmalik appointed Umayya b. 'Abdillah b. Khalid b. Asid as governor of Khorasan in 74 A.H. (693-4 A.D.), with Sistan included under his governorship. Umayya sent his son Abdullah as head of the expedition in Sistan. Though initially successful, the new Zunbil was able to defeat them. Per some accounts, Abdullah himself was killed. Umayya was dismissed and Sistan added to governorship of al-Hajjaj ibn Yusuf.

Under Al-Hajjaj

Al-Hajjaj, who had become governor of Iraq and the East in 78 A.H. (697–98), had appointed Ubaidallah, who was a mawla of mixed Abyssinian and Iraqi-Persian origins, as his deputy in Sistan. The Zunbils who had been left unchecked had completely stopped paying the tribute. This provided a pretext to terminate the peace between the both sides. Ubaidallah was appointed for an expedition against them in 698 and was ordered by Al-Hajjaj to "attack until he laid waste to Zunbil's territories, destroyed his strongholds, killed all his fighting men and enslaved his progeny". The ensuing campaign was called the "Army of Destruction" (Jaish al-Fana). However, it ended disastrously for the Arabs.

Al-Baladhuri's account on the authority of Al-Mada'ini in Futuh al-Buldan and Ansab al-Ashraf, is the fullest documentation of the campaign. Tabari's account runs parallel but is based on Abu Mikhnaf and does not include the poem of A'sha Hamdan included in Ansab al-Ashraf. Ibn Qutaybah's Kitab al-Ma'arif only makes a bare mention. Ta'rikh al-khulafa' has a more detailed account and epitomises accounts of Tabari and Baladhuri. Tarikh-e-Sistan confuses the campaign with another one against the Khwarij of Zarang. The army consisted of Iraqis from Basra and Kufa, though Baladhuri mentions presence of some Syrians. Ubaidallah himself led the Basrans while the Tabi Shuraih b. Hani' al-Harithi ad-Dabbi led the Kufans.

They marched to Zamindawar or al-Rukhkhaj (the classical Arachosia) but found it was barren and foodless. Their advance probably happened in summer of 698 as A'sha Hamdan's poem refers to the scorching heat they had to endure. In Zabulistan's regions of Ghazna and Gardiz, they plundered a significant amount of cattle and other animals in addition to destroying various strongholds. The Zunbils who were devastating the countryside whilst retreating, were luring the Arabs into a trap to an inhospitable and foodless terrain. Futuh al-Buldan states that the Muslims almost penetrated Kabul. Tabari meanwhile says that they came within 18 farsakhs of the summer capital of Zunbils in the Qandahar region.

The plan of the Zunbils worked and they trapped the Arabs into a valley. Ubaidallah realizing the gravity of the situation, offered 500,000 or 700,000 dirhams as well as his three sons along with some Arab leaders as hostages while promising not to raid again during his tenure as Sistan's governor. Shuraih, who had earlier advised retreat, felt a withdrawal would be dishonorable. He was joined by a group of people into the battle, and all but a handful of them were killed. The remnant of the Arab army withdrew back to Bust and Sistan, suffering from starvation and thirst. Many died in the "Desert of Bust", presumably the Registan Desert, with only 5,000 making it back to Bust. Many of those who survived died by gorging themselves on the food sent to them according to Tabari. Ubaidallah had arranged food for them after seeing their suffering and himself died, either from grief or an ear affliction.

Al-Hajjaj prepared another expedition in 699, reportedly of 40,000 troops from Kufa and Basra under Abdurrahman b. Muhammad b. al-Ash'ath. Though disguised as a military expedition, it was actually a forced migration of the elements from the two Iraqi cities troublesome to Hajjaj. It was equipped to the best standards and was called the "Army of Peacocks" because of the men included in its ranks. It included proudest and most distinguished leaders of Iraq led by Ibn al-Ash'ath, grandson of Al-Ash'ath ibn Qays. It also included distinguished elders who served in the first armies of conquest as well as those who fought at Battle of Siffin. This Arab army arrived in Sistan in the spring of 699.

The Arabs advanced east into Zabulistan and won several victories. However the troops didn't want to fight in this inhospitable region and started becoming restive. Al-Hajjaj instructed them to continue the advance into Zabulistan's heart no matter what it took, making it clear to them he wanted them to return to their homes. Ibn al-Ash'ath also made an agreement with the Zunbils, that no tribute would be demanded if he won and in case he lost, he would be sheltered to protect him from Al-Hajjaj. The troops mutinied against Hajjaj's enforced emigration and returned to Iraq but were crushed by the Syrian troops. They fled back to the east while Ibn al-Ash'ath fled to Sistan where he died in 704 A.D.

When Ibn al-Ash'ath returned to Sistan in 702-703 A.D., he wasn't allowed into Zarang and fled to Bust where he was abducted by Iyad b. Himyan al-Bakri as-Sadusi, who he had appointed as the deputy over Bust, so Iyad could resecure favor of al-Hajjaj. Zunbil however attacked the town and threatened to slaughter or enslave everyone there unless Ibn al-Ash'ath was handed over to him. Iyad set him free and he went to Zunbil's territory along with his army. Zunbil was persuaded by Al-Hajjaj's representative to surrender him. His fate is however unclear. Per some accounts, he committed suicide while according to others he was killed by the Zunbil who sent his head to the Umayyads in Sistan. Following this, a truce was declared between Al-Hajjaj and Zunbil in return for the latter paying tribute in kind and in return, Al-Hajjaj promised not to attack him.

From 8th century

Qutayba b. Muslim, the conqueror of Transoxiana, preferred not to fight the Zunbils and accepted an offer of a rather minimal tribute from them, calling Sijistan an "ill-omened front". Until the reign of Hisham ibn Abd al-Malik, the Sijistan front had ceased to be volatile as the Arabs had given up on conquering the area and no fighting occurred for a long period. This in turn holding led to Zunbils not even paying a token tribute. The policy began to change under Hisham. Khalid al-Qasri in Iraq appointed Yazid b. al Ghurayf al-Hamdani as Sistan's governor, a Syrian from Jund al-Urdunn, in 725. Yazid resumed the campaign by sending an army under the command of Balal b. Abi Kabsha. They however did not obtain anything from the Zunbils.

The new governor of Sistan, al-Asfah b. 'Abd Allah al-Kalbi, a Syrian, embarked on ambitious policy of campaigning against the Zunbils. The first one was carried out in 726. During the second one in late 727-728, he was warned by the Sijistanis who were with him to not campaign in winter especially in mountain defiles. Per Ya'qubi, his army was completely annihilated by the Zunbils. Per Tarikh al-Sistani, al-Asfah managed to get back to Sistan where he died. The next two governors didn't undertake any campaigns. Zunbil was unable to take advantage of the annihilation of al-Asfah's army but the defeat was a heavy one. It would become one in a series of blows for the caliphate.

The Sistan front remained quiet in latter part of Abd al-Malik's reign except perhaps the Kharjite activity, with long tenures and blank records of 'Abd Allah b. Abi Baruda and Ibrahim b. 'Asim al-'Uqayli suggesting that the instability in the region had been controlled to extent. It appears this was only possible because no more campaigns were undertaken against the Zunbils.

Al-Mansur sent Ma'n b. Zaida ash-Shabani sent to Sistan in response to disturbances in Sistan. Ma'n along with his nephew Yazid b. Ziyad undertook an expedition against the Zunbil for making him obedient and restoring the tribute not paid since the time of al-Hajjaj. It is especially well-documented by al-Baladhuri. He ordered the Zunbil to pay the tribute and was offered camels, Turkish tents and slaves, but this did not placate him. Per al-Baldahuri, under the reign of al-Mansur, Hisham b. 'Amr al-Taghlibi after conquering Kandahar, destroyed its idol-temple and built a mosque in its place.

Ma'n and Yazid advanced into Zamindawar but the Zunbil had fled to Zabulistan. They nonetheless pursued and defeated him, taking 30,000 as captives including Faraj al-Rukhkhaji, who would later become a secretary of the department of private estates of the Caliph under al-Ma'mun. Zunbil's deputy Mawand (Zunbil's son-in-law Mawld in Tarikh-e-Sistan) offered submission which was requested and he was sent with 5,000 of their soldiers to Baghdad where he was treated kindly and given pensions along with his chieftains per Baladhuri.

The tribute was paid by the Zunbils to amils of caliphs al-Mahdi and ar-Rashid, though rather irregularly. When the Caliph Al-Ma'mun (r. 813–833 A.D.) visited Khorasan, he was paid double the tribute by Rutbil, but was evidently left unmolested and the Arabs later subdued Kabul.

Kabul Shahi

The area had been under the rule of the Turk Shahi who took over the rule of Kabul in the seventh century and later were attacked by the Arabs. The Turk Shahi dynasty was Buddhist and were followed by a Hindu dynasty shortly before the Saffarid conquest in 870 A.D. Al-Ma'mun's expeditions were the last Arab conflict against Kabul and Zabul and the long-drawn conflict ended with the dissolution of the empire. Muslim missionaries converted many people to Islam; however, the entire population did not convert, with repetitive revolts from the mountain tribes in the Afghan area taking place. The Hindu Shahi were defeated by Mahmud of Ghazna (r. 998-1030) who expelled them from Gandhara and also encouraged mass-conversions in Afghanistan and India.

When Ar-Rabi b. Ziyad reached Helmand, the Zunbils held power as far as Zarang. The Kabulshah was a subordinate of the Zunbil. Subsequent to the first Arab clashes with the Zunbils and Kabulshahs, we find the Zunbil negotiating with the representatives of the Caliph "for his own country and the land of Kabul." The Zunbils were linked to the Turki Shahi dynasty of Kabul, which was at the time a cultural and religious outpost of the Indian world.

During the caliphate of Uthman, new popular uprisings had broken out in Persia and continued for five years from 644–649. The revolts were suppressed and Abdullah b. Amir, who was appointed governor of Basra, had captured many cities including Balkh, Herat and Kabul. After Muawiyah became the Caliph, he prepared an expedition under 'Abd ar-Rahman b. Samura to Khorasan. Per Baladhuri, after recapturing Zarang as well as conquering other cities, they besieged Kabul for a few months and finally entered it. Per the historian Firishta, while capturing Kabul in 664 A.D., Samura had made converts of some 12,000 people. Kabul's ruler was obliged to pay a tribute. This didn't last long as he soon drove out the Arabs from his lands after Samura's death. A treaty was renegotiated but about the time of death of Yazid I, "the people of Kabul treacherously broke the compact". The Arab army sent to reimpose it was routed.

In about 680-683, the Shah fled from his brother Rutbil and approached Salm b. Ziyad at Amul in Khorasan where he accepted his suzerainty. The reason for the Shah's refuge is not known. After his successes in Zabulistan, the Rutbil may have assumed a threatening position to him, causing him to seek help of Arabs. A treaty was agreed with the Shah though its terms are not known. He was allowed to settle down in Amul (or at least under Amul's jurisdiction somewhere north of Hindu Kush). Per Tabari, Salm was elated at this and wrote to Mu'awiyah who disapproved of it. When asked the reason, he responded that "there is a lot of ill-will and bad feeling in Zaranj and Amul. The people living in the lands between these two places are disloyal and treacherous. They are likely to take advantage of the moment of our weakness and, then, it would be easier for them to capture the territory up to Amul". And it precisely happened after Muawiyah's death per Tabari.

The Shah captured Amul and became powerful enough to threaten Rutbil who went into hiding. Zunbil's brother, 'al-Shah also besieged Zaranj, but the Turks retreated after reinforcements arrived from Basra. Abdur Rehman who studied the descriptions of Tabari however stated that these events should be seen as having happened in Yazid's time since Salm was governor under his reign. In 152 A.H. (769 A.D.), Humayd ibn Qahtaba, the governor of Khorasan, raided Kabul. According to Ibn al-Athir, al-'Abbas b. Ja'far led an expedition against Kabul sent by his father Ja'far b. Muhamamad in 787–78, which Bosworth claims is the one attributed to Ibrahim b. Jibril by Al-Ya'qubi.

The only record of an event in early Abbasid period obviously related to the area south of the Hindu Kush, is the expedition against Kabul in 792-793 ordered by Al-Fadl ibn Yahya and led by Ibrahim b. Jibril. It is mentioned by al-Tabari's chronicle, the tenth century Kitāb al-Wuzarā'wa al-Kuttāb of al-Jahshiyari and by al-Ya'qubi. Per al-Jahshiyari, he conquered Kabul and acquired a lot of wealth. Al-Ya'qubi states that rulers and landlords of Tukharistan, including Bamiyan's king, joined this army, implying it crossed Hindu Kush from the north. It also mentions subjugation of "Ghurwand" (present-day Ghorband). He also mentions the "Pass of Ghurwand" which judging by the itinerary of the expedition from Tukharistan to Bamiyan to Ghorband valley, is identical to Shibar Pass. They then marched to Shah Bahar where an idol venerated by the locals was destroyed. The inhabitants of various towns then concluded peace treaties with Fadl, one of which was identified by Josef Markwart as Kapisa.

Al-Ma'mun (r. 813–833 A.D.) while visiting Khorasan, launched an attack on Kabul, whose ruler submitted to taxation. The king of Kabul was captured and he then converted to Islam. Per sources, when the Shah submitted to al-Ma'mun, he sent his crown and bejeweled throne, later seen by the Meccan historian al-Azraqi to the Caliph who praised Fadl for "curbing polytheists, breaking idols, killing the refractory" and refers to his successes against Kabul's king and ispahabad. Other near-contemporary sources however refer to the artifacts as a golden jewel-encrusted idol sitting on a silver throne by the Hindu Shahi ruler or by an unnamed ruler of "Tibet" as a sign of his conversion to Islam.

Qutayba's campaigns

Qutayba b. Muslim was appointed the governor of Khorasan in 705 by al-Hajjaj b. Yusuf, the governor of Iraq and the East. He began his rule with the reconquest of western Tokharistan in the same year. Qutayba who was tasked with subduing the revolt in Lower Tokharistan, led the final conquest of Balkh. His army was assembled in spring of 705 and marched to Balkh. Per one version of al-Tabari, the city was surrendered peacefully. Another version, speaks of a revolt among the residents. In 706, he received the submission of Nizak, the leader of Badghis. In 707, he marched on Bukhara oasis along with Nizak in his army but the campaign didn't achieve any major objective.

According to Baldhuri, when Qutayba ibn Muslim became the governor of Khorasan and Sistan, he appointed his brother 'Amr to Sistan. 'Amr asked the Zunbil to pay tribute in cash but he refused, prompting Qutayba to march against him. The campaign was also partially encouraged by his desire to eliminate the support of the southern Hepthalites, the Zabulites, for their northern brethren to revolt. Zunbil who was surprised by this unexpected move and scared of his reputation, quickly capitulated. Qutayba, realizing the real strength of the Zunbils, accepted it and returned to Merv, leaving only an Arab representative in Sistan.

Per Al-Mada'ini, Qutayba returned to Merv after conquering Bukhara in 709. The rebellion of the Hepthalite principalities from region of Guzgan including Taloqan and Faryab, led Qutayba to dispatch 12,000 men from Merv to Balkh in winter of 709. The rebellion was led and organized by Nizak Tarkhan and was supported by Balkh and Marw al-Rudh's dihqan Bādām. Nizak had realised that independence wouldn't be possible if Arab rule was strengthened in Khorasan, and perhaps was also encouraged by Qutayba's attempts to achieve his objectives through diplomacy. The success of Zunbils may also have encouraged him.

Nizak wrote to the Zunblis asking for help. In addition, he also forced the weak Jābghū of Tokharistan to join his cause to persuade all princes of the Principalities of Tukharistan to do the same. His plan to stage the revolt in spring of 710 was however spoilt by Qutayba. Badham fled when Qutayba advanced on Marw al-Rudh but his two sons were caught and crucified by Qutayba who next marched to Taloqan. Taloqan was the only place in his campaign where the inhabitants weren't given a complete amnesty, concerning which H.A.R. Gibb states the "traditions are hopelessly confused". Per one account, he executed and crucified a band of bandits there, though it is possible it was selected for this severity as it was the only place where there was an open revolt.

Faryab and Guzgan both submitted and their inhabitants were not harmed. From there he went on to receive the submission of people of Balkh. Almost all of Nizak's princely allies had reconciled themselves with him and there were Arab governors in all towns of Tokharistan, spoiling his plans. He fled south to the Hindu Kush, hoping to reach Kabul and entrenched himself in an inaccessible mountain pass guarded by a fortress. The Arabs succeeded in gaining the fort with help of Ru'b Khan, ruler of Ru'b and Siminjan. Nizak fled along the modern road that leads from the Oxus valley to Salang Pass and holed up in an unidentified mountain refuge in a site of Baghlan Province. Qutayba caught up with him and besieged him for two months.

Sulaym al-Nasih (the counsellor), a mawla of Khorasan, helped in obtaining his surrender to Qutayba who promised a pardon. Nonetheless, he was executed along with 700 of his followers after orders from al-Hajjaj. The Jabghu of Tokharistan was sent as a valuable hostage to Damascus. He then went in pursuit of Juzjan's king, who requested amnesty and called for exchange of hostages as precautionary measure. This was agreed upon and Habib b. 'Abd Allah, a Bahilite, was sent as prisoner by Qutayba while the king sent some of his family members in return. The peace treaty was agreed but the king died in Taloqan on his return journey. His subjects accused the Muslims of poisoning him and killed Habib, with Qutayba retaliating by executing Juzjan's hostages.

Other regions

Ghur

Tabari records that in 667 A.D., Ziyad b. Abihi had sent Hakam b. 'Amr al-Ghafri to Khorasan as Amir. Hakam raided Ghur and Farawanda, bringing them to submission through force of arms and conquered them. He obtained captives and a large amount of plunder from them. A larger expedition was undertaken under Asad ibn Abdallah al-Qasri, the governor of Khorasan, who raided Gharchistan in 725, receiving its submission as well as the conversion of its king to Islam. He next attacked Ghur whose residents hid their valuables in an inaccessible cave, but he was able to plunder the wealth by lowering men in crates.

Asad's success prompted him to undertake a second expedition in 108-109 A.H. against Ghur. The poet Thabit Qutna's eulogical poem of Asad recorded by Tabari called it a campaign against the Turks saying, "Groups of the Turks who live between Kabul and Ghurin came to you, since there was no place in which they might find refuge from you." Bosworth states that this campaign may have actually taken place in Guzgan or Bamiyan rather than the purely-Iranian Ghur. He also states that no doubt further sporadic raids continued throughout the Umayyad rule, though not noted by historians. It is known that Nasr ibn Sayyar's commander Sulaiman b. Sul had raided Gharchistan and Ghur some time before 739 A.D.

The early history of Ghor is unclear. Minhaj-i-Siraj in Tabaqat-i-Nasiri states that Shansab, who established the Ghurid dynasty, was converted by the Arab Caliph Ali which Mohammad Habib and K. A. Nizami dismissed as unlikely. He further adds that the Ghurid Amir Faulad assisted Abu Muslim in overthrowing the Umayyads during the Abbasid Revolution. He also recounts a legend about a dispute between two prominent families of the area. They sought the intercession of the Abbasids and the ancestor of the Shansabi family, Amir Banji, was subsequently confirmed as the ruler by Harun al-Rashid.

No permanent control was ever established on Ghur. According to Bosworth, its value was only for its slaves which could best be obtained in occasional temporary raids. Arab and Persian geographers never considered it important. In all sources it is cited as supplying slaves to slave markets in Khorasan, indicating it had a mostly "infidel" population. Istakhari called it a land of infidels (dar al-kufr) annexed to Islamic domain because of its Muslim minority. However Hudud al-'Alam stated it had a mostly-Muslim population.

Ghazna

The pre-Ghaznavid royal dynasty of Ghazna were the Lawiks. Afghan historian 'Abd al-Hayy Habibi Qandahari who in 1957 examined a manuscript containing tales about miracles (karamat) of Shaikh Sakhi Surur of Multan who lived in the 12th century, concluded it dated to 1500. He recorded one of its anecdotes which records history of Ghazna by the Indian traditionalist and lexicographer Radi ad-Din Hasan b. Muhammad al-Saghani [died 1252] from Abu Hamid az-Zawuli. According to it, a great mosque at Ghazna was earlier a great idol-temple built in honor of the Rutbils and Kabul-Shahs by Wujwir Lawik. His son Khanan converted to Islam and was sent a poem by the Kabul-Shah saying, "Alas! The idol of Lawik has been interred beneath the earth of Ghazna, and the Lawiyan family have given away [the embodiment of] their kingly power. I am going to send my own army; do not yourself follow the same way of the Arabs [ie., Islam]."

Habibi continues stating that Khanan later reconverted to the faith of the Hindu-Shahis. His grandson Aflah however upon assuming power demolished the idol-temple and built a mosque in its place. When the saint Surur arrived at the mosque, he is said to have found the idol of Lawik and destroyed it. The Siyasatnama of Nizam al-Mulk, the Tabaqat-i Nasiri of Juzjani and the Majma' al-ansāb fī't-tawārīkh of Muhammad Shabankara'i (14th century) mention Lawik. Juzjani gives the Lawik who was defeated by Alp-tegin the Islamic kunya of Abu Bakr though Shabankara'i claims he was a pagan. A variant of his name appears as Anuk in Tabaqat-i Nasiri.

Bamyan

Ya'qubi states that lord of Bamyan called the Shēr, was converted to Islam under Caliph Al-Mansur (d.775) by Muzahim b. Bistam who married his son Abu Harb Muhammad to his daughter. However, in his history he changes it to the rule of Al-Mahdi (r. 775–785). Ya'qubi also states that Al-Fadl ibn Yahya made Hasn, Abu Harb Muhammad's son, as the new Shēr after his successful campaign in Ghorband. Ya'qubi states that the ruler of Bamiyan had accompanied an expedition dispatched by Al-Fadl ibn Yahya in 792-793 against Kabul Shahi.

Later Shers remained Muslim and were influential at the Abbasid court. However, Muslim sources describe the Saffarid ruler Ya'qub ibn al-Layth al-Saffar looting Bamiyan's pagan idols. A much later historian Shabankara'i claims that Alp-Tegin obtained conversion of Sher to Islam in 962. It seems there were lapses to Buddhism among some of the rulers as the Muslim influence grew weak. However, there is no evidence about the role of Buddhism during these periods or whether Buddhist monasteries remained the center of religious life and teaching.

Post-Arab rule

Tahirids

Khurasan was the base for early recruitment of Abbasid armies, especially the Abbasid takeover received support from Arab settlers aiming to undermine the important sections of non-Muslim aristocracy. The Abbasids succeeded in integrating Khorasan and the East into the central Islamic lands. The state was gradually Persianized through political influence and financial support of the dihqans. Al-Ma'mun emerged as the victor in Fourth Fitna with the help of Khorasani forces. But this also ended up turning the province into a virtually independent state under the Tahirids, founded by a Persian mawla who rose to favour under Al-Ma'mun.

According to Ibn Khordadbeh, the Shah of Kabul had to send 2,000 Oghuz slaves worth 600,000 dirhams as annual tribute to the governor of Khorasan Abdallah ibn Tahir (828-845). In addition to the Oghuz slaves, he also had to pay an annual tribute of 1.5 million dirhams. Mid-9th century, one of their tributaries Abu Da'udid or Banijurid Amir Da'ud b. Abu Da'ud Abbas, undertook an obscure campaign into eastern Afghanistan and Zabulistan that was profitable. It is recorded that in 864 Muhammad ibn Tahir sent two elephants captured at Kabul, idols and aromatic substances to the caliph.

Saffarids

Ya'qub b. al-Layth

The Tahirid rule was overthrown by Ya'qub ibn al-Layth al-Saffar of Sistan, the first independent Iranian ruler in the post-Islamic era and fought the Abbasid Caliphate. He joined the 'ayyar band of Salih b. al-Nadr/Nasr, who was recognised as Bust's amir in 852. al-Nasr aimed at taking over whole of Sistan and drove out the Tahirid governor in 854, with Sistan ceasing to be under direct control of the Caliphate. al-Nasr himself was overthrown by Dirham b. Nasr who was overthrown by Ya'qub in 861. Ya'qub and his brother Amr advanced as far as Baghdad and to Kabul itself in eastern Afghanistan with their dynamism, advancing along the historic route taken by the modern Lashkargah-Qandahar-Ghazni-Kabul road. Their eastern campaigns are documented by Arabic sources of Al-Masudi's Murūj adh-dhahab, Ibn al-Athir's al-Kāmil fi't-tā'rīkh and Tarikh-e-Sistan. The Persian historian Gardizi's Zain al-akhbār also mentions the Saffarid campaigns.

Salih fled to ar-Rukhkhaj or Arachosia, where he received the help of the Zunbil. Both Salih and the Zunbil were killed by Ya'qub in 865. Abu Sa'id Gardezi mentions that Ya'qub advanced from Sistan to Bust and occupied the city. From here he advanced to Panjway and Tiginabad (two of the chief towns of Arachosia), defeating and killing the Zunbil, though the date isn't given. This account matches with that of Tarikh-e-Sistan. Satish Chandra states that, "We are told that it was only in 870 AD that Zabulistan was finally conquered by one Yakub who was the virtual ruler of the neighbouring Iranian province of Siestan. The king was killed and his subjects were made Muslims."

Muhammad Aufi's Jawami ul-Hikayat meanwhile states that during his invasion of Zabul, he employed a ruse to surrender after being allowed to pay homage to the ruler along with his troops lest they disperse and become dangerous to both sides. Yaqub's troops "carried their lances concealed behind their horses and were wearing coats of mail under their garments. The Almighty made the army of Rusal (probably Rutbil), blind, so that they did not see the lances. When Yaqub drew near Rusal, he bowed his head as if to do homage, but raised a lance and thrust it in the back of Rusal so that he died on the spot. His people also fell like lightning upon the enemy, cutting them down with their swords and staining the earth with the blood of the enemies of the religion. The infidels when they saw the head of Rusal upon the point of a spear took to flight and great bloodshed ensued. This victory, which he achieved, was the result of treachery and deception, such as no one had ever committed."

Ashirbadi Lal Srivastava states that after this victory by Yaqub over Zabul, the position of Lallya alias Kallar, the Brahmin minister who had overthrown the last Kshatriya king of Kabul Lagaturman, seems to have become untenable. He shifted his capital to Udhaband in 870 A.D. Lallya, credited as an able and strong ruler by Kalhana in Rajatarangini, was driven out by Ya'qub from Kabul within a year of his usurpation according to Srivastava.

Gardezi states that after defeating Zunbil, he then advanced into Zabulistan and then Ghazna, whose citadel he destroyed and forced Abu Mansur Aflah b. Muhammad b. Khaqan, local ruler of nearby Gardez, to tributary status. Tarikh-e-Sistan however in contrast states that he returned to Zarang after killing Salih. This campaign may be related to Gardizi's account of later expedition in 870 where he advanced as far as Bamiyan and Kabul. Salih b. al-Hujr, described as a cousin of the Zunbil, was appointed as the Saffarid governor of ar-Rukhkhaj, but rebelled two years after Zunbil's death and committed suicide to avoid capture.

Ya'qub had captured several relatives of the Zunbil's family after defeating Salih b. al-Nasr. Zunbil's son escaped from captivity in 869 and quickly raised an army in al-Rukhkhaj, later seeking refuge with the Kabul-Shah. Per Gardizi, Ya'qub undertook another expedition in 870 which advanced as far as Kabul and Bamiyan. According to Tarikh-e-Sistan, Bamiyan was captured in 871. He wrested Bamiyan from its ruler, the Sher, and plundered its idol-temple. He defeated Kabul in 870 and again had to march to there in 872 when Zunbil's son took possession of Zabulistan. Ya'qub captured the Zunbil's son from the fortress of Nay-Laman where he had fled. In 871, Ya'qub sent 50 gold and silver idols he gained by campaigning from Kabul to Caliph Al-Mu'tamid, who sent them to Mecca.

According to Tabaqat-i-Nasiri, Ghor which was ruled by Amir Suri in the 9th century entered into a war against  him, but escaped conquest due to its difficult and mountainous terrain.

Amr b. al-Layth

After Ya'qub's death in 879, Al-Mu'tamid recognised his brother and successor 'Amr b. al-Layth (r. 879–902), as governor of Khorasan, Isfahan, Fars, Sistan and Sindh. The caliph however announced divesting him of all his governorships in 885 and reappointed Muhammad b. Tahir as the governor of Khorasan. He was reappointed governor of Khorasan in 892 by Al-Mu'tadid.

Amr led an expedition as far as Sakawand in the Logar valley, between Ghazna and Kabul, described as a Hindu pilgrimage-centre. In 896, he sent idols captured from Zamindawar and the Indian frontier, including a female copper idol with four arms and two girdles of silver set with jewels pulled on a trolley by camels, to Baghdad. Al-Baihaki mentions Sakawand as a pass from Kabul to India. It was situated at or near Jalalabad. The idol taken from somewhere in eastern Afghanistan by Amr was displayed for three days in Basra and then for three days in Baghdad. Jamal J. Elias states that it may have been of Lakshmi or Sukhavati at Sakawand. Al-Masudi emphasises the attention it received as a spectacle, with crowds gathering to gawk at it.

Aufi states that Amr had sent Fardaghan as the prefect over Ghazna and he launched the raid on Sakawand, which was a part of the territory of Kabul Shahi and had a temple frequented by Hindus. The Shah of Kabul at this time was Kamaluka, called "Kamalu" in Persian literature. Fardaghan entered it and succeeded in surprising Sakawand. Sakawand was plundered, and its temple destroyed.

Kamalu counter-attacked Fardaghan who realising his forces were no match for his, resorted to spreading a false rumour that he knew his intentions and had organised a formidable army against him with 'Amr on the way to join him. The rumour had the desired effect and the opposing army slowed its advance knowing that they could be ambushed and slaughtered if they advanced impetuously into the narrow defiles. Meanwhile, Fardaghan received reinforcements from Khorasan according to Aufi. According to Aufi he cleverly averted the danger.

Tarikh-e-Sistan doesn't mention any attack by Fardaghan on Sakawand however, instead beginning with the attack by Kamalu. Per it, when Amr was in Gurgan, he heard that Nasad Hindi and Alaman Hindi had allied and invaded Ghazna. The Saffarid governor 'Fard 'Ali was defeated and fled.

Samanids

The Samanids came to rule over areas including Khorasan, Sistan, Tokharistan and Kabulistan after Ismail (r. 892907) in 900 A.D. had defeated the Saffarids, who had taken over Zabulistan and the Kabul region. The Turks were highly noted for their martial prowess by the Muslim sources and were in high demand as slave-soldiers (ghulam, mamluk) by the Caliphate in Baghdad and the provincial emirs. The slaves were acquired either in military campaigns or through trade. The Samanids were heavily involved in this trade of Turkish slaves from lands to the north and east of their state. As the enslavement was limited to non-Muslims and with the Turks increasingly adopting Islam beyond Samanid borders, they also entered Transoxiana as free men due to various causes.

The Ghaznavids arose indirectly from the atmosphere of disintegration, palace revolutions and succession putschs of the Samanid Empire. Abu-Mansur Sabuktigin was one of the Samanid slave guards who rose from the ranks to come under the patronage of the Chief Hajib Alp-Tegin. After the death of the Samanid Amir 'Abd al-Malik b. Nuh, the commander of forces in Khorasan Alp-Tegin along with the vizier Muhammad Bal'ami attempted to place a ruler of their choice on the throne. The attempt failed however and Alp-Tegin decided to withdraw to the eastern fringes of the empire. Per the sources, he wanted to flee to India to avoid his enemies and earn divine merit by raiding the Hindus. He didn't intend to capture Ghazna, but was forced to take it when denied transit by its ruler.

Alp-Tegin proceeded with his small force of ghulams and ghazis (200 ghulams and 800 ghazis according to Siyasatnama, while Majma al-ansab of Muhammad b. Ali al-Shabankara'i (d. 1358) states 700 ghulams and 2,500 Tajiks). En route, he subdued the Iranian Sher of Bamiyan and the Hindu-Shahi king of Kabul. He then came to Ghazna whose citadel he besieged for four months and wrested the town from its ruler, Abu 'Ali or Abu Bakr Lawik or Anuk. The origin of this chief was Turkic, though it is not known if he was a Samanid vassal or an independent ruler. Josef Markwart suggests he was a late representative of the Zunbils. The Lawik dynasty of Ghazna was linked to the Hindu-Shahi dynasty through marriage. Alp-Tegin was accompanied by Sabuktigin during the conquest of Ghazna.

Minhaj al-Siraj Juzjani states that Alp-Tegin had his position regularised by Amir Mansur b. Nuh through an investiture, however Siyasatnama mentions an expedition against Alp-Tegin from Bukhara which was defeated outside Ghazna. His ambiguous, semi-rebel status seems to be reflected in his coins, with two of his coins minted at Parwan mentioning his authority from the Samanids to mint coins only in an indirect way. He was succeeded by his son Abu Ishaq Ibrahim, who lost Ghazna to Abu Ali Lawik, the son of its expelled ruler. He recovered it however with Samanid help in 964-65.

Alp-Tegin's ghulams were reconciled with the Samanids in 965 but maintained their autonomy. After Ibrahim's death in 966, Bilge-Tigin was made the successor and he acknowledged the Samanids as his overlords. He died in 976 and was succeeded by Piri or Piri-tigin. Piri's misrule led to resentment among the people who invited Abu Ali to take back the throne. The Kabul Shahis allied with him and the king, most likely Jayapala, sent his son to assist Lawik in the invasion. When the allied forces reached near Charkh on Logar River, they were attacked by Sabuktigin who killed and captured many of them while also capturing ten elephants. Piri was expelled and Sabuktigin became governor in 977 A.D. The accession was endorsed by the Samanid ruler Nuh II.

The Hudud al-‘Alam states Ghor was under the overlordship of Farighunids. Both Gardezi and Baihaqi state in 379 A.H. (979–980 A.D.), the Samanid Amir Nuh b. Mansur despatched an expedition under Abu Ja'far Zubaidi to conquer Ghur but he had to return after capturing several forts. As the Samanid governor of Zabulistan and Ghazni, Sabuktigin attacked it several times. He was able to conquer eastern Ghur after initial set-backs and was acknowledged as a sovereign by Muhammad ibn Suri.

Ghaznavids

Sabuktigin

First war against Jayapala

The Ghaznavid campaigns from the time of Sabuktigin are recorded as jihad against the people of al-Hind to destroy idolatry and replace it by expanding Islam. The Kabul Shahis only retained Lamghan in the Kabul-Gandhara area by the time of Alp-tegin. According to Firishta, Sabuktigin had already begun raiding Lamghan under Alp-tegin. This precipitated an alliance between the Shahi ruler Jayapala and the Muslim Amirs of Multan. He crossed the Khyber Pass many times and raided the territory of Jaipala.

Sabuktigin plundered the forts in the outlying provinces of the Kabul Shahi and captured many cities, acquiring huge booty. He also established Islam at many places. Jaipal in retaliation marched with a large force into the valley of Lamghan (Jalalabad) where he clashed with Sabuktigin and his son. The battle stretched on several days until a snow storm affected Jaipala's strategies, forcing him to plead for peace. He was inclined to grant peace to Jayapala but his son Mahmud wanted total victory.

Jaypala upon hearing Mahmud's plans warned, "You have seen the impetuosity of the Hindus and their indifference to death... If therefore, you refuse to grant peace in the hope of obtaining plunder, tribute, elephants and prisoners, then there is no alternative for us but to mount the horse of stern determination, destroy our property, take out the eyes of our elephants, cast our children into fire, and rush out on each other with sword and spear, so that all that will be left to you to conquer and seize is stones and dirt, dead bodies, and scattered bones." Knowing he could carry it out, Sabuktigin granted him peace on promise of paying tribute and ceding some of his territory.

Second war against Jayapala

After making peace with Sabuktigin, Jayapala returned to Waihind but broke the treaty and mistreated the amirs sent to collect the tribute. Sabuktigin launched another invasion in retaliation. While the mamluks remained 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 butcher the idolaters, destroyed their temples and plundered their shrines. It is said 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 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 A.D., 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 appointed Ismail as successor to his kingdom and died in 997. A succession war erupted between Ismail and Mahmud, with the latter gaining the throne in 998.

Sultan 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

Mahmud systemized plunder raids into India as a long-term policy of the Ghaznavids. The first raid was undertaken in September 1000, but was meant for reconnaissance and identifying the possible terrain and roads that could be used for future raids.  He reached Peshawar by September 1001 and was attacked by Jayapala. The two sides clashed on 27–28 November 1001 with Jayapala captured. Anandapala who was at Waihand had to pay a heavy ransom to have his father and others released. Jaypala self-immolated out of shame and Anandpala succeeded him. Mahmud attacked Anandpala later over his refusal to allow him passage during the attack on Multan controlled by Fateh Daud. The two sides clashed in 1009 in the eastern side of Indus at Chhachh, with Mahmud defeating Anandapala and capturing the fort of Bhimnagar. He was allowed to rule as a feudatory in Punjab for some time.

An alliance between Anandpala's son, Trilochanpala, and Kashmiri troops was defeated. During the warfare from 990-91 to 1015, Afghanistan, and later Punjab and Multan were lost to the Ghaznavids. Trilochanpala's rule was limited to eastern Punjab and he gained respite from the Muslim invasions with retreat to Sirhind. He allied with the Chandellas
and in 1020-21 was defeated at a river called Rahib by Al-Utbi, while Firishta and Nizamuddin Ahmad identify it as Yamuna. He was killed in 1021 A.D. by his mutinous troops and succeeded by Bhimapala. Bhimapala who was the last ruler, was killed fighting the Ghaznavids in 1026 A.D. The remnants of the royal family sought refuge with the Lohara dynasty of Kashmir and Punjab passed under the control of Muslim conquerors.

Mahmud used his plundered wealth to finance his armies which included mercenaries. The Indian soldiers, presumably Hindus, who were one of the components of the army with their commander called sipahsalar-i-Hinduwan lived in their quarter of Ghazna practicing their own religion. Indian soldiers under their commander Suvendhray remained loyal to Mahmud. They were also used against a Turkic rebel, with the command given to a Hindu named Tilak according to Baihaki.

The renowned 14th-century Moroccan Muslim scholar Ibn Battuta remarked that the Hindu Kush meant the "slayer of Indians", because slaves brought from India who had to pass through there died in large numbers due to the extreme cold and quantity of snow. He states:

Invasions of Ghur

The conversion of Ghur occurred over a long period and it was mostly pagan until the 10th century, which Mohammad Habib and Khaliq Ahmad Nizami say was probably a result of the missionary activities by the Karramiyya movement established in the region in 10th-11th centuries. Its imperfect conversion is visible by the fact that while the people of Ghur had Muslim names, they led the life of pagans. Muhammad b. Suri who had acknowledged Sabuktigin as his sovereign, withheld tribute after his death, started plundering caravans and harassed the subjects of Sultan Mahmud. Rawżat aṣ-ṣafāʾ called him a pagan, al-Utbi stated he was a Hindu.

In 1011, Mahmud despatched an expedition to conquer Ghur under Altuntash, governor of Herat, and Arslan Hajib, governor of Tus. Muhammad b. Suri, the king, placed himself in inaccessible hills and ravines. The Ghurids were however defeated and Suri was captured along with his son Shith. Abu Ali, who had remained on good terms with the Sultan, was made the ruler of Ghur by him. Eastern Ghur was brought under Ghaznavid control. In 1015, Mahmud attacked Ghur's southwestern district of Khwabin and captured some forts.

In 1020, Mahmud's son Ma'sud was despatched to take Ghur's northwestern part called Tab. He was helped by Abul Hasan Khalaf and Shirwan, chieftains of the south-western and north-eastern regions respectively. He captured many forts, bringing entire Ghur except maybe the inaccessible interior under Ghaznavid control. He also captured the stronghold of the chieftain Warmesh-Pat of Jurwas, levying a tribute of arms. Minhaj al-Siraj Juzjani praises Abu Ali for firmly establishing Islamic institutions in Ghur. The progress of Islam in this divided region after his death is however unknown.

Ghur remained a pagan enclave until the 11th century. Mahmud who raided it, left Muslim precepts to teach Islam to the local population. The region became Muslim by 12th century though the historian Satish Chandra states that Mahayana Buddhism is believed to have existed until the end of the century. Neither Mahmud nor Ma'sud conquered the interior. Habib and Nizami say Ghurids were gradually converted by propagandists of new mystic movements. The Shansabani succeeded in establishing their seniority, if not its unification. By the time of Sultan Bahram, Ghur was converted and politically unified. According to Minhaj, both Ghiyasuddin and Mu'izzuddin were Karamis who later converted to Shafi‘i and Hanafi Islam respectively. The Tarikh-i guzida however says the Ghorids were only converted to Islam by Mahmud.

Conversion of Pashtun-Afghan people

The name Afghanistan was first used in a political sense by Saifi Herawi in the 14th century. It was even used during the height of the Durrani Empire. Only after the Durand line was fixed, did its modern usage for the land between it and the Oxus river became usual. The people who were mostly responsible for establishing the Afghan kingdom are referred to as Pashtun. The name Pashtun (or Pakthun) is the original and oldest name.

The tenth-century Persian geography Hudud al-'Alam is the earliest known mention of the Afghans. In Discourse on the Country of Hindistan and Its Towns, he states that, "Saul, a pleasant village on a mountain. In it live Afghans." Ibn Battuta described Saul being situated between Gardez and Husaynan along a common trade route, the exact location of Husaynan is unknown. Akhund Darweza states their original homeland was Qandahar from where they migrated in 11th century upon Mahmud of Ghazni's request to assist him in his conquests. Afghan tradition considers "Kase Ghar" in Sulayman range as the homeland. Hudud al-'Alam also mentions that the king of Ninhar (Nangarhar) had many wives including "Moslem, Afghan and Hindu".

The Pashtun traditions speak of Islamization during Muhammad's time through Khalid ibn Walid. Qais Abdur Rashid, the presumed ancestor of the Afghans, is said to have led a delegation to Mecca from Ghor after being summoned by Khalid b. Walid and converted to Islam while also distinguishing himself in the service of the prophet. Adopting the name Abdul Rashid, three sons - Saraban, Ghurghust, Karlani, and a foundling Karlanri linked to Saban, are the progenitors of the major Afghan divisions.

Ni'matullah's Makhzan-i-Afghani traces their history to an Israelite called Afghana who constructed the al-Aqsa mosque. Per it under the time of King Suleiman, a figure named Bokhtnasser was responsible for "carrying away the Israelites, whom he settled in the mountainous districts of Ghor, Ghazneen, Kabul, Candahar, Koh Firozeh, and the parts lying within the fifth and sixth climates; where they, especially those descended of Asif and Afghana, fixed their habitations, continually increasing in number, and incessantly making war on the infidels around them." Qais traveled to Medina to receive Mohammed's blessings and fought against the Meccans. Muhammad himself conferred the title of Pashtun upon Qais and his people. They returned to Ghor to spread Islam and pledged loyalty to Mahmud. Per Ni'matullah, the Ghurid ruler Mu'izz al-Din had initiated their eastward migration into present-day north-west Pakistan, in course of his military campaigns.

The Arabs, at war with the Kabul Shah, had directed their campaigns in direction of Gandhara. By the time of Muawiya, Sistan's governorship was separated from Khorasan with the governor looking after the region and keeping a check on Kabul Shah. Ahmed Hassan Dani considers that the Arab activities may have led to conversion of Aghans as well, and it may have been wholesale because of their tribal nature ie all the Afghan tribes adopted Islam at once.

Quoting Matla-al-Anwar, Ferishta states a man named Khalid, son of Abdullah, stated by some to be a descendant of Khalid bin Walid or Abu Jahl, was for some time governor of Herat, Ghor, Gharjistan and Kabul. After being relieved of the charge, he settled in Koh Sulaiman, with the Lodis and Suris being the descendant of his daughter who married a converted Afghan. Only he continues with Afghan history after this. He states that the Hindu Shahi king gave them a few villages in Laghman in return for guarding against the Arabs. He adds that after being unable to withstand Sabuktigin's raids, Jaipala appointed the Afghan Shiekh Hamid Lodhi to an Amirate but Lodhi was removed after Sabuktigin became supreme in Ghazni. Ferishta speaks of the Afghans here as Muslims.

Al-Utbi in Tarikh-i-Yamini states that the Afghans were enlisted by Sabuktigin and also Mahmud. During this period, the Afghan habitat was in the Sulaiman Mountains. After defeating Jayapala in 988 A.D., Sabuktigin had acquired the territory between Laghman and Peshawar. Al-Utbi states that the Afghans and Khaljis, living there as nomads, took the oath of allegiance to him and were recruited into his army.Iqtidar Husain Siddiqui citing the 13th century Persian translation, claims he mentions the "Afghans" were pagans given to rapine and rapacity, they were defeated and converted to Islam.

Writing in the 11th century AD, Al-Biruni in his Tarikh al Hind, stated that the Afghans tribes lived in mountains as west of India. He notes, "In the western frontier mountains of India there live various tribes of the Afghans and extend up to the neighbourhood of the Sindu valley." 

Mahmud had gone to war against pagan Afghan while campaigning in the Sulayman mountains. Firishta states that Afghans fought on both sides during the war between Mu'izz al-Din and Pithorai in 1192 AD, which Encyclopaedia of Islam says probably indicating they weren't completely converted.

In 1519, Babur mounted an attack on the fort of Bajaur and sent a Dilazak Afghan as an ambassador to the Gibri Sultan of Bajaur, Mir Haidar 'Ali, to surrender and enter his services. Gibri, a Dardic language of Bajaur, was also spoken by the royal family and nobility of the Swat Valley. The Gibris decided to resist and Babur's forces stormed it in two days. He ordered a general massacre of its inhabitants on the pretext that they had rebelled against Kabul's regime and were infidels who had forsaken Islam.

The westward migration of Pashtuns from Sulaiman mountains to Qandahar and Herat is thought to have begun in the 15th century. In the 16th century, the area around Qandahar formed a bone of contention between Ghilzai and Abdalis. The latter gave in and migrated to Herat during the reign of Safavid Shah Abbas I. Their migration displaced or subjugated the indigenous populations especially the Tajiks who were also the dominant population in Kabul, Nangarhar and Laghman in east Afghanistan. Before advent of Ghilzais of the Ahmadzai division in the late 16th century, Logar River was also a Tajik stronghold. The Pashtuns also displaced the original Kafirs and Pashayi people in Kunar Valley and Laghman valley, located south of Kabul in east Afghanistan, to the infertile mountains. Regions to south and east of Ghazni were stronghold of Hazaras before the 16th century. They also lost Wardak to the tribe of the same name when the latter invaded in the 17th century. In Qandahar, the Farsiwanis, Hazaras, Kakars and Baloch people were subjugated.

Conquests of Kafiristan 

Kafiristan is a mountainous region of the Hindu Kush that was isolated and politically independent until the Afghan conquest of 1896. Before their conversion to Islam, the Nuristanis or Kafir people practiced a form of ancient Hinduism infused with locally developed accretions.

Kafiristan proper from west to east comprises basins of Alishang, Alingar, Pec or Praisun, Waigal and Bashgal. The region became a refuge of an old group of Indo-European people probably mixed with an older substratum, as well as a refuge of a distinct Kafiri group of Indo-Iranian languages, forming part of the wider Dardic languages. The inhabitants were known as "kafirs" due to their enduring paganism while other regions around them became Muslim. However, the influence from district names in Kafiristan of Katwar or Kator and the ethnic name Kati has also been suggested. The Kafirs were divided into Siyah-Posh, comprising five sub-tribes who spoke Lato language while the others were called Safed-Posh comprising Prasungeli, Wangeli, Wamais and Ashhkun.

The Kafirs called themselves "Balor", a term that appeared in Chinese sources as early as the fifth century A.D. Both Chinese sources and Muslim sources like the 16th-century work of Kashmir's conqueror Mirza Muhammad Haidar Dughlat, the terms "Bolor" and "Boloristan" denote the area from the Kabul valley to Kashmir, Yarkand and Kashgar. The country is the most inaccessible part of Hindu Kush. The Muslim conquerors could not achieve a lasting success here.

The area extending from modern Nooristan to Kashmir was known as "Peristan", a vast area containing host of "Kafir" cultures and Indo-European languages that became Islamized over a long period. Earlier, it was surrounded by Buddhist areas. The Islamization of the nearby Badakhshan began in the 8th century and Peristan was completely surrounded by Muslim states in the 16th century with Islamization of Baltistan. The Buddhist states temporarily brought literacy and state rule into the region. The decline of Buddhism resulted in it becoming heavily isolated.

There have been varying theories about the origins of the Kafirs. Oral traditions of some Nuristanis place themselves to be at confluence of Kabul and Kunar River a millennium ago, being driven off from Kandahar to Kabul to Kapisa to Kama with the Muslim invasion. They identify themselves as late arrivals here, being driven by Mahmud of Ghazni who after establishing his empire forced the unsubmissive population to flee. George Scott Robertson considered them to be part of the old Indian population of Eastern Afghanistan and stated they fled to the mountains while refusing to convert to Islam after the Muslim invasion in the 10th century. The name Kator was used by Lagaturman, last king of the Turk Shahi. The title "Shah Kator" was assumed by Chitral's ruler Mohtaram Shah who assumed it upon being impressed by the majesty of the erstwhile pagan rulers of Chitral. The theory of Kators being related to Turki Shahis is based on the information of Jami- ut-Tawarikh and Tarikh-i-Binakiti. The region was also named after its ruling elite. The royal usage may be the origin behind the name of Kator.

Mahmud of Ghazna

In 1020–21, Sultan Mahmud of Ghazna led a campaign against Kafiristan and the people of the "pleasant valleys of Nur and Qirat" according to Gardizi. The Persian chronicles speak of Qirat and Nur (or Nardin) which H. M. Elliot on authority of Al-Biruni identifies with Nur and Kira tributaries of Kabul river. Ferishta wrongly calls these two valleys as "Nardin" and Qirat and confuses this conquest with the one against "Nardin" or Nandana. He also wrongly mentions it took place after 412 A.H. Alexander Cunningham identifies the places conquered as "Bairath" and "Narayanpura".

These people worshipped the lion. While Clifford Edmund Bosworth considers that Mahmud attacked "pagan Afghans", Joseph Theodore Arlinghaus of Duke University doesn't consider it correct because his source Gardezi simply calls them "pagan (kafiran)" and not "pagan Afghans", as they weren't known to be pagan or live on borders of Nooristan in the 11th century. Mohammed Habib however considers they might have been worshipping Buddha in form of a lion (Sakya Sinha). Ramesh Chandra Majumdar states they had a Hindu temple which was destroyed by Mahmud's general. Ram Sharan Sharma states that they may have been Buddhist. Cunningham claims based on the reporting of Ferishta that the place was plundered by 'Amir Ali after being taken.

According to Gardezi, while returning from invasion of India, he had heard about them and the chief of Qirat surrendered without any struggle and accepted to convert, with the inhabitants converting as well. Nur however refused to surrender and his general 'Amir Ali led an attack on it and forcing its people to convert. According to Firshta, the rulers of both of them submitted and accepted Islam in 1022. He adds, "On breaking a great temple situated there, the ornamented figure of a lion came out of it, which according to the belief of the Hindus was four thousand years old."

However, no permanent conquest was attempted. Iqbal namah-i-Jahangiri stated that Kafirs still lived in Darrah-i-Nur Sultan Mahmud of Ghazni claimed to have converted. Mughal Emperor Jahangir had received a delegation of these pure Kafirs in Jalalabad and had honored them with gifts.

Timurids

The campaigns of Timur are recorded by Zafarnama written by Sharaf ad-Din Ali Yazdi, based on another work.
 On his way to India, Timur attacked the Siyah-Posh in 1398 A.D. after receiving complaints from the trading city of Andarab by raids from Kafirs. He penetrated it from Khawak pass and restored an old fortress there. He personally proceeded against the Kator region which extended from Kabul to Kashmir.

Timur sent a detachment of 10,000 soldiers against Siyah-Poshas under Burhan Aglan and had the fort of Kator deserted by Kafirs destroyed while the houses of the city were burnt. The infidels took refuge on top of a hill and many were killed in the ensuing clash. Some held out for three days but agreed to convert after Timur offered them the choice between death and Islam. They however soon apostatised and ambushed Muslim soldiers in the night. They were however repelled and a number of the Kafirs were killed, with 150 taken prisoner and later executed. Timur ordered his men "to kill all the men, to make prisoners of women and children, and to plunder and lay waste all their property." His soldiers carried out the order and he directed them to build a tower of skulls of the dead Kafirs.

Timur had his expedition engraved on a neighboring hill in the month of Ramazan. His detachment sent against Siyah-Poshas however met with disaster with Aglan routed and fleeing. A small detachment of 400 men under Muhammad Azad was sent and defeated the Kafirs, retrieving the horses and armour Aglan lost. Timur later captured a few more places, though nothing more is stated, presumably he left the Siyah-poshas alone. He proceeded to exterminate the rebellious Afghan tribes and crossed the Sindhu River in September 1398.

The Timurid Sultan Mahmud Mirza is said to have raided Kafiristan twice by Baburnama, which earned him the title of ghazi.

Yarkand Khanate

Mirza Muhammad Haidar Dughlat invaded Balor under orders of Sultan Said Khan in 1527-1528 A.D. and was accompanied by Khan's eldest son Rashid Khan. The expedition was an Islamic frontier raid or ghaza. Dughlat undertook highly devastating plundering raids on Bolor.

Rashid Khan (r. 1533–1569) undertook further expeditions against Bolor (Kafiristan) which are recorded by Tarikh-i-Kashgar and Bahr al-asar of Mahmud b. Amir Wali. The Kashgari author mentions it briefly though Wali goes into detail. The first campaign failed with a number of Kashgari captured and enslaved by the people of Bolor. A second invasion was successful and forced them to submit. Tarikh-i-Kashgar states that Bolor was governed by Shah Babur after Abdullah Khan's successful campaign in 1640.

Mughals

Babur writing in his memoirs notes that when he captured Chigha Sarai in 1514, the "Kafirs of Pech came to their assistance." He mentions some Muslim nīmčas or half-breeds, probably converted Kafirs, who married with the Kafirs and lived at Chigha Sarai, located at confluence of Kunar River and Pech River.

Babur himself came to the region in the winter of 1507–1508 and had an inscription carved commemorating his transit. While fleeing to India to take refuge in Afghan-Indian borderlands after Shibani Khan attacked Qandahar, which Babur had recently conquered, he marched from Kabul to Lamghan in September 1507. He eventually reached Adinapur fort in Nangarhar district. He comments that his men had to forage for food and raided the rice fields of the Kafirs in the Alishang district. In 1520, he mentions sending Haidar Alamdar to the Kafirs who returned and met him under Bandpakht along with some Kafir chiefs who gifted Babur some skins of wine.

The relationship of the Siahposh and residents of Panjshir and Andarab remained the same even more than a century after Timur's expedition. Babur records about Panjshir that, "It lies upon the road, and is in the immediate vicinity of Kafiristan. The inroads of the robbers of Kafiristan are made through Panjshir. In consequence of their vicinity of the Kafirs - the inhabitants of this district are happy to pay them a fixed contribution. Since I last invaded Hindustan, and subdued it (in 1527), the Kafirs have descended into Panjshir, and returned after slaying a great number of people and committing extensive damages."

Per Tabakat-i-Akbari, Mughal Emperor Akbar had dispatched his younger brother Mirza Muhammad Hakim, who was a staunch adherent of the missionary-minded Naqshbandi Sufi order, against the infidels of Katwar in 1582. Hakim was a semi-independent governor of Kabul. The Sifat-nama-yi Darviš Muhammad Hān-i Ğāzī of Kadi Muhammad Salim who accompanied the expedition mentions its details. The Sifat-nama gives Muhammad Hakim the epithet of Darviš Khan Gazi.

Muhammad Darvish's religious crusade fought its way from Lamghan to Alishang, and is stated to have conquered and converted 66 valleys to Islam. After conquering Tajau and Nijrau valleys in Panjshir area, the crusaders established a fort at Islamabad at confluence of Alishang and Alingar rivers. They continued the raid up to Alishang and made their last effort against the non-Muslims of Alingar, fighting up to Mangu, the modern border between Pashai and Ashkun-speaking areas.

The conquest doesn't seem to have had a lasting effect as Henry George Raverty mentions that Kafirs still lived in upper part of Alishang and Tafau. Khulasat al-ansab of Hafiz Rahmat Khan stated that the Afghans and Kafirs of Lamghan were still fighting each other during the time of Jahangir.

Final subjugation

Under Amir Sher Ali Khan, Afghanistan was divided into provinces (wilayats) of Kabul, Kandahar, Herat and Afghan Turkestan. Uruzgan and Kafiristan were later incorporated into Kabul. Some parts of Kafiristan were already following Islam before its conquest. Amir Abdul Rahman Khan tried to persuade them to convert to Islam by deputing Kafir elders. The Kafirs were poorly armed as compared to Afghans and numbered only 60,000. By 1895, demarcation of nearby Chitral under indirect British rule and conquest of Pamirs by Russia worried him about the endangerment of integration of Afghanistan through the independent Kafiristan. Afghan tribes meanwhile undertook slave raids in places like Kafiristan, Hazarajat, Badakhshan and Chitral.

The territory between Afghanistan and British India was demarcated between 1894 and 1896. Part of the frontier lying between Nawa Kotal in outskirts of Mohmand country and Bashgal Valley on outskirts of Kafiristan were demarcated by 1895 with an agreement reached on 9 April 1895. Abdur Rahman wanted to force every community and tribal confederation with his single interpretation of Islam due to it being the only uniting factor. After the subjugation of Hazaras, Kafiristan was the last remaining autonomous part. Field marshal Ghulam Hayder Khan sent a message to Kafirs of Barikut which stated, "It is not the duty of the government to compel, force or impose on them to accept, or take the path of the religion of Islam. The obligation that does exist is this: they render obedience and pay their taxes. As long as they do not disobey their command, they will not incinerate themselves with the fire of padishah's [king's] wrath. In addition, they are not to block the building of the road [that was planned through their territory]."

Emir Abdur Rahman Khan's forces invaded Kafiristan in the winter of 1895–1896 and captured it in 40 days according to his autobiography. Columns invaded it from the west through Panjshir to Kullum, the strongest fort of the region. The columns from the north came through Badakhshan and from the east through Asmar. A small column also came from south-west through Laghman. The Kafirs were forcibly converted to Islam and resettled in Laghman while the region was settled by veteran soldiers and other Afghans. Kafiristan was renamed as Nooristan. Other residents also converted to avoid the jizya.

His victory was celebrated with the publishing of a poem in 1896 or 1897 and Faiz Mohammad Katib Hazara gave him the title "Idol-Smasher". About 60,000 of the Kafirs became converts. Mullahs were deployed after the conquest to teach them about fundamentals of Islam. The large-scale conversion proved difficult however and the complete Islamization took some time. Kafir elders are known to have offered sacrifices in their shrines on rumors of Rahman's death in 1901. Three main roads connecting Badakhshan with Kunar and Lamghan (Chigha Sirai-Munjan, Asmar-Badakhshan and Munjan-Laghman) were built after the conquest.