Turk Shahi–Arab conflicts

Background
The Turk Shahis, or Kabul Shahis, were a dynasty of Turkic or mixed Turko-Hephthalite origin that ruled from Kabul and Kapisa to Gandhara between the 7th and 9th centuries AD. They may have been of Khalaj ethnicity, and their territory bordered the Kashmir and Kannauj kingdoms. In the 560s, the Western Turks expanded southeast from Transoxonia, taking control of Bactria and the Hindu Kush, forming independent states. The Turk Shahis possibly emerged as an extension of the Western Turk Yabghus of Tokharistan and replaced the Nezak Huns, the last rulers of Bactria.

The Turk Shahis came to power after the Sasanian Empire fell to the Rashidun Caliphate and resisted the Abbasid Caliphate’s eastward expansion for over 250 years. Eventually, in the 9th century AD, the dynasty fell to the Persian Saffarids.
The Conflicts
Barha Tegin Conflict with Arabs
Under Barha Tegin, the Shahis launched a counter-attack and drove the Arab forces out after Abd al-Rahman ibn Samura was replaced as Governor of Sistan around 665 CE. They regained lost territory, including areas like Arachosia and Kandahar. The capital was moved from Kapisa to Kabul. In 671 CE, when Rabi ibn Ziyad al-Harithi became the governor of Sistan, the Arabs tried to attack again, fighting the Turkic leader "Rutbil" at Bost and forcing him to retreat to al-Rukhkhaj (Arachosia). Rabi's successor, Ubayd Allah ibn Abi Bakra, continued the fighting in 673 CE, leading Rutbil to agree to a peace deal. The agreement gave control of Kabul and Zabul to Rutbil and the King of Kabul, with the governor of Sistan recognizing their authority. Not much is known about Barha Tegin's rule, but many early Turk Shahi coins are linked to him.
Tegin Shah Conflict with Arabs
Tegin Shah became the ruler around 680, after his father. His land included the areas from Kabulistan to Gandhara, and at first, it also included Zabulistan. His older brother, Rutbil, who founded the Zunbil dynasty, ruled Zabulistan. Although their relationship was sometimes hostile, they worked together to fight off Arab attacks.

In 683, the Arabs tried again to capture Kabul and Zabulistan, but their general Abu Ubaida ibn Ziyad was captured in Kabul, and Yazid ibn Ziyad, the governor of Sijistan, was killed while attacking the city. For a short time in 684–685, the Arabs took control of Kabul. In 698, the Umayyad general Ubayd Allah ibn Abi Bakra led an army against the Zunbils, but he was defeated and had to pay a large tribute, give hostages, including three of his sons, and promise not to invade Zunbil again. Around 700, Ibn al-Ash'ath tried again to invade with the 'Peacock Army,' but after making some progress, he reached a peace deal with the Turks and later led a rebellion against the Umayyad viceroy, al-Hajjaj ibn Yusuf.

By around 710, Tegin Shah regained control over Zabulistan. Chinese records say that the rulers of Zabulistan submitted to Kabul between 710 and 720. During this time, the Zunbils and Turk Shahis sometimes paid taxes to the Arabs, acknowledging some control, but resisted when the Arabs tried to take more power over them.
Arab Invasion of Zunbil Turk Shahi
The Arabs often claimed control over the Zunbils. In 711, Qutayba ibn Muslim made the Zunbils pay tribute. However, in 725–726, Yazid ibn al-Ghurayf, the governor of Sistan, was unable to do the same. The Arabs would not receive tribute from the Zunbils again until 769 CE, when Ma'n b. Za'ida al-Shaybani defeated them near Ghazni.
Fromo Kesaro Victory over Arabs

In 739 CE, Tegin abdicated in favour of his son Fromo Kesaro:

"Fromo Kesaro" is probable phonetic transcription of "Rome Caesar". He was apparently named in honor of "Caesar", the title of the then East Roman Emperor Leo III the Isaurian who had defeated their common enemy the Arabs during the Siege of Constantinople in 717 AD, and sent an embassy to China through Central Asia in 719 AD which probably met with the Turk Shahis.

Fromo Kesaro seems to have successfully fought against the Arabs. His coins suggest that the Arabs were defeated and had to pay tribute to him. This is shown by Sasanian coins and coins from Arab governors, which were overstruck by Fromo Kesaro with a message in the Bactrian script.

Bo Fuzhun Conflict with Arabs
In 745 AD, Bo Fuzhun, the son of Fromo Kesaro, became the king, according to the Old Book of Tang..He was also given the title "General of the Left" by the Tang dynasty, which suggests a close relationship between the Chinese and the Turk Shahis, especially as the Islamic empires were expanding.

Around 760 AD, the Chinese left the region after being defeated at the Battle of Talas in 751 AD and dealing with the An Lushan Rebellion. This weakened the Turk Shahis' power. Between 775 and 785 AD, a ruler of Kabul, possibly named Hanhal, Khinkhil, Khingil, or Khingal, received a proposal from the Abbasid Caliph Al-Mahdi asking for his submission. He was either a unique ruler of the Turk Shahis or identical with Bo Fuzhun.天寶四年,又冊其子勃匐準為襲罽賓及烏萇國王,仍授左驍衞將軍。"Kesar's son Bo Fuzhun succeed him on the throne as the king of Jibin and Wuchang. He was conferred the title General of the Left Stalwart Guard" in  This ruler agreed, and he might have been the same person as Bo Fuzhun.

Abbasids Invasion of Zunbil Turk Shahi
After the Abbasids took control in 750, the Zunbils formally submitted to the third Abbasid Caliph al-Mahdi (reigned 775–785), but these submissions were likely not sincere. The people in the region continued to resist Muslim rule. The Muslim historian Ya'qubi (died 897/8) in his Ta'rikh ("History") mentions that al-Mahdi asked for, and seemingly received, the submission of several rulers from Central Asia, including the Zunbils.

In 769 CE, the Arabs were able to get tribute from the Zunbils again after almost 50 years, when Ma'n b. Za'ida al-Shaybani defeated them near Ghazni.

Arab attacks are recorded around 795 CE. The Muslim writer Kitāb al-Buldan tells of the destruction of a place called Sah Bahar, believed to be Tepe Sardar. The Arabs attacked the Sah Bahar, where people worshipped idols, and they destroyed and burned them.

Harun Al Rashid Expeditions against Turk Shahis
Harun Al Rashid led Two Expedition against the Turk Shahis in one in 769 and another in 786 in both the expeditions Arabs were defeated and the Invasion was repulsed.
Renewed conflict with the Arabs and decline of Turk Shahis and Failure against Zunbil Turk Shahis

The conflict between the Arabs and the Turk Shahis continued into the 9th century AD. During the Great Abbasid Civil War (811-819 AD), the Turk Shahis, called "Pati Dumi" in Arab sources, took advantage of the situation and invaded parts of Khorasan. After the Abbasid caliph Al-Ma'mun won the Civil War, he sent troops to fight the Turk Shahis. In 814/815 AD, the Arabs defeated the Turk Shahis and pushed into Gandhara. As a result, the Turk Shahi ruler had to convert to Islam, pay an annual tribute of 1,500,000 dirhams and 2,000 slaves, and give a valuable idol made of gold, silver, and jewels to be sent to Mecca. This story was first told by Al-Azraqi in 834 AD, and later written by Quṭb ed-Dîn.

Al-Azraqi also gave a detailed description of a statue, which shows a Buddha wearing a crown and jewels while sitting on a throne. This design is well-known and typical for the time period in the regions of Afghanistan and Kashmir. Another military campaign against the Gandhara area likely happened soon after, with the Caliphate reaching the Indus River and dealing a major defeat.

The Zunbils repulsed the Al-Ma'mun's raids and kept ruling for about 20 more years. However, they later became involved in a conflict with Saffarids that led to their downfall.
Aftermath
Establishment of Hindu Shahis
The Turk Shahis were in a difficult situation, and around 843 CE, the last ruler, Lagaturman, was overthrown by one of his ministers, a Brahmin named Kallar. According to the historian Al-Biruni, Lagaturman’s bad behavior led his people to complain to Kallar. Kallar found a hidden treasure and used it to gain power. He imprisoned the king for corruption and became the regent before taking the throne for himself. Kallar then started a new dynasty called the "Hindu Shahi" in Gandhara. No other sources mention Kallar, and little is known about his rule, the areas he controlled, or how long he ruled.
Fall of Zunbil Turk Shahis
In 870 AD, the Muslim leader Yaqub bin Laith al-Saffar defeated the Zunbils, a group in eastern Afghanistan. Yaqub, who was the founder of the Saffarid dynasty, began his conquests by first defeating the Kharijites in Herat and then moving on to other areas. He conquered the Zunbil territory in Ghazna, then advanced to Bamyan and Kabul, pushing the Hindu Shahis further east. By 870 AD, Yaqub controlled all of Khorasan and the Panjshir Valley, allowing him to mint silver coins.

This marked the first time Muslim forces successfully expanded into eastern Afghanistan after over 200 years of resistance from local rulers. The Hindu Shahis continued to resist the spread of Islam until around 1026 AD.
Notes

 References 

Category:7th-century conflicts
Category:Wars involving Asia
Category:Ancient India