The History of Khyber Pakhtunkhwa refers to the history of the modern-day Pakistani province of Khyber Pakhtunkhwa.

The earliest evidence from the region indicates that trade was common via the Khyber Pass; originating from the Indus Valley Civilization. The Vedic culture reached its peak between the 6th and 1st centuries B.C under the Gandharan Civilization, and was identified as a center of Hindu and Buddhist learning and scholarship.

Following Alexander the Great's invasion, the region became part of the Mauryan Empire, followed by the Indo-Greeks, Indo-Scythians and Indo-Parthians.

The region of Gandhara reached its height under Kushan Empire in 2nd and 3rd century AD. Over time the Turk Shahis managed to gain control of the region and ruled starting from around the sixth century, but were later overthrown by the Hindu Shahis. The Hindu Shahis were finally destroyed after the defeat of King Jayapala in A.D 1001 by the Ghaznavids led by Mahmud of Ghazni. After the Ghaznavids, various other Islamic rulers had managed to invade the region, with the most notable being the Delhi Sultanates who had with respect to various dynasties ruled starting from A.D 1206. The Mughals had taken control of the region, and managed to rule until the early 18th century when they were displaced by the rule of the Durranis and briefly by Barakzai Dynasty until early 19th century. After the end of Durrani rule, modern-day Khyber Pakhtunkhwa became part of the Sikh empire, who later lost the territory to the British Empire around 1857, and had ruled until the Indo-Pakistani Independence of 1947. After the independence of Pakistan, the area was renamed Khyber Pakhtunkhwa after widespread petitioning to the Pakistan government by the local Pashtuns. Today, the area is a key province in the war on terror; and aside from terrorism, the province continues to face many developmental challenges.

Bronze age Indus Valley Civilization During the times of Indus Valley civilisation (3300 BC – 1700 BC) the Khyber Pass through Hindu Kush provided a route to other neighbouring empires and was used by merchants on trade excursions.

Iron age Vedic era The region of Gandhara, which was primarily based in the area of modern-day Khyber Pakhtunkhwa features prominently in the Rigveda (), as well as the Zoroastrian Avesta, which mentions it as Vaēkərəta, the sixth most beautiful place on earth created by Ahura Mazda. It was one of the 16 Mahajanapadas of Vedic era. It was the centre of Vedic and later forms of Hinduism. Gandhara was frequently mentioned in Vedic epics, including Rig Veda, Ramayana and Mahabharata. It was the home of Gandhari, the princess of Gandhara Kingdom.*Schmidt, Karl J. (1995). An Atlas and Survey of South Asian History, p.120: "In addition to being a center of religion for Buddhists, as well as Hindus, Taxila was a thriving center for art, culture, and learning." Srinivasan, Doris Meth (2008). "Hindu Deities in Gandharan art," in Gandhara, The Buddhist Heritage of Pakistan: Legends, Monasteries, and Paradise, pp.130–143: "Gandhara was not cut off from the heartland of early Hinduism in the Gangetic Valley. The two regions shared cultural and political connections and trade relations and this facilitated the adoption and exchange of religious ideas. [...] It is during the Kushan Era that flowering of religious imagery occurred. [...] Gandhara often introduced its own idiosyncratic expression upon the Buddhist and Hindu imagery it had initially come in contact with." Blurton, T. Richard (1993). Hindu Art, Harvard University Press: "The earliest figures of Shiva which show him in purely human form come from the area of ancient Gandhara" (p.84) and "Coins from Gandhara of the first century BC show Lakshmi [...] four-armed, on a lotus." (p.176)

Ancient history Alexander's conquests In the spring of 327 BC Alexander the Great crossed the Indian Caucasus (Hindu Kush) and advanced to Nicaea, where Omphis, king of Taxila and other chiefs joined him. Alexander then dispatched part of his force through the valley of the Kabul River, while he himself advanced into Bajaur and Swat with his light troops. Craterus was ordered to fortify and repopulate Arigaion, probably in Bajaur, which its inhabitants had burnt and deserted. Having defeated the Aspasians, from whom he took 40,000 prisoners and 230,000 oxen, Alexander crossed the Gouraios (Panjkora) and entered the territory of the Assakenoi and laid siege to Massaga, which he took by storm. Ora and Bazira (possibly Bazar) soon fell. The people of Bazira fled to the rock Aornos, but Alexander made Embolima (possibly Amb) his base, and attacked the rock from there, which was captured after a desperate resistance. Meanwhile, Peukelaotis (in Hashtnagar, north-west of Peshawar) had submitted, and Nicanor, a Macedonian, was appointed satrap of the country west of the Indus.

Mauryan rule

Mauryan rule began with Chandragupta Maurya displacing the Nanda Empire, establishing the Mauryan Empire. A while after, Alexander's general Seleucus had attempted to once again invade the subcontinent from the Khyber pass hoping to take lands that Alexander had conquered, but never fully absorbed into this empire. Seleucus was defeated and the lands of Aria, Arachosia, Gandhara, and Gedrosia were ceded to the Mauryans in exchange for a matrimonial alliance and 500 elephants. With the defeat of the Greeks, the land was once more under Hindu rule. Chandragupta's son Bindusara further expanded the empire. However, it was Chandragupta's grandson Ashoka, who converted to Buddhism and made it the official state religion in Gandhara and also Pakhli, the modern Hazara, as evidenced by rock-inscriptions at Shahbazgarhi and Mansehra.

After Ashoka's death the Mauryan empire fell to pieces, just as in the west the Seleucid power was waning.

Indo-Greeks

The Indo-Greek king Menander I (reigned 155–130 BC) drove the Greco-Bactrians out of Gandhara and beyond the Hindu Kush, becoming king shortly after his victory.

His empire survived him in a fragmented manner until the last independent Greek king, Strato II, disappeared around 10 AD. Around 125 BC, the Greco-Bactrian king Heliocles, son of Eucratides, fled from the Yuezhi invasion of Bactria and relocated to Gandhara, pushing the Indo-Greeks east of the Jhelum River. The last known Indo-Greek ruler was Theodamas, from the Bajaur area of Gandhara, mentioned on a 1st-century CE signet ring, bearing the Kharoṣṭhī inscription "Su Theodamasa" ("Su" was the Greek transliteration of the Kushan royal title "Shau" ("Shah" or "King")).

It is during this period that the fusion of Hellenistic and South Asian mythological, artistic and religious elements becomes most apparent, especially in the region of Gandhara.

Local Greek rulers still exercised a feeble and precarious power along the borderland, but the last vestige of the Greco-Indian rulers were finished by a people known to the old Chinese as the Yuezhi.

Indo-Scythian Kingdom

The Indo-Scythians were descended from the Sakas (Scythians) who migrated from Central Asia into South Asia from the middle of the 2nd century BC to the 1st century BC. They displaced the Indo-Greeks and ruled a kingdom that stretched from Gandhara to Mathura. The first Indo-Scythian king Maues established Saka hegemony by conquering Indo-Greek territories.The Grandeur of Gandhara, Rafi-us Samad, Algora Publishing, 2011, p.64-67 The power of the Saka rulers declined after the defeat to Chandragupta II of the Gupta Empire in the 4th century.Ancient India by Ramesh Chandra Majumdar p. 234

Indo-Parthian Kingdom

The Indo-Parthian Kingdom was ruled by the Gondopharid dynasty, named after its first ruler Gondophares. For most of their history, the leading Gondopharid kings held Taxila (in the present Punjab province of Pakistan) as their residence, but during their last few years of existence the capital shifted between Kabul and Peshawar. These kings have traditionally been referred to as Indo-Parthians, as their coinage was often inspired by the Arsacid dynasty, but they probably belonged to a wider groups of Iranic tribes who lived east of Parthia proper, and there is no evidence that all the kings who assumed the title Gondophares, which means "Holder of Glory", were even related.

Kushan Empire

The Yuezhi nomads had driven the Sakas from the highlands of Central Asia, and were themselves forced southwards by the nomadic Xiongnu. One group, known as the Kushan, took the lead, and its chief, Kadphises I, seized vast territories extending south to the Kabul valley. His son Kadphises II conquered North-Western India, which he governed through his generals. His immediate successors were the fabled Buddhist kings: Kanishka, Huvishka, and Vasushka or Vasudeva, of whom the first reigned over a territory which extended as far east as Benares, far south as Malwa, and also including Bactria and the Kabul valley. Their dates are still a matter of dispute, but it is beyond question that they reigned early in the Christian era. To this period may be ascribed the fine statues and bas-reliefs found in Gandhara and Udyana. Under Huvishka's successor, Vasushka, the dominions of the Kushan kings shrank.

Turk and Hindu Shahis

The Turk Shahis ruled Gandhara until 870, when they were overthrown by the Hindu Shahis. The Hindu Shahis are believed to belong to the Uḍi/Oḍi tribe, namely the people of Oddiyana in Gandhara.

The first king Kallar had moved the capital into Udabandhapura from Kabul, in the modern village of Hund for its new capital.The Shahi Afghanistan and Punjab, 1973, pp 1, 45–46, 48, 80, Dr D. B. Pandey; The Úakas in India and Their Impact on Indian Life and Culture, 1976, p 80, Vishwa Mitra Mohan – Indo-Scythians; Country, Culture and Political life in early and medieval India, 2004, p 34, Daud Ali.Journal of the Royal Asiatic Society, 1954, pp 112 ff; The Shahis of Afghanistan and Punjab, 1973, p 46, Dr D. B. Pandey; The Úakas in India and Their Impact on Indian Life and Culture, 1976, p 80, Vishwa Mitra Mohan – Indo-Scythians.India, A History, 2001, p 203, John Keay.Sehrai, Fidaullah (1979). Hund: The Forgotten City of Gandhara, p. 2. Peshawar Museum Publications New Series, Peshawar. At its zenith, the kingdom stretched over the Kabul Valley, Gandhara and western Punjab under Jayapala. Jayapala saw a danger in the consolidation of the Ghaznavids and invaded their capital city of Ghazni both in the reign of Sebuktigin and in that of his son Mahmud, which initiated the Muslim Ghaznavid and Hindu Shahi struggles. Sebuk Tigin, however, defeated him, and he was forced to pay an indemnity. Jayapala defaulted on the payment and took to the battlefield once more. Jayapala however, lost control of the entire region between the Kabul Valley and Indus River.

However, the army was defeated in battle against the western forces, particularly against the Mahmud of Ghazni. In the year 1001, soon after Sultan Mahmud came to power and was occupied with the Qarakhanids north of the Hindu Kush, Jaipal attacked Ghazni once more and upon suffering yet another defeat by the powerful Ghaznavid forces, near present-day Peshawar. After the Battle of Peshawar, he died because of regretting as his subjects brought disaster and disgrace to the Shahi dynasty.

Jayapala was succeeded by his son Anandapala, who along with other succeeding generations of the Shahiya dynasty took part in various unsuccessful campaigns against the advancing Ghaznvids but were unsuccessful. The Hindu rulers eventually exiled themselves to the Kashmir Siwalik Hills.

Medieval period Ghaznavids