She then played a crucial role in freeing him from a second captivity in Lahore. She helped organize an elaborate escape plan involving a tunnel, a sewer, a boat and a succession of horses. Wafa Begum later charmed the British into giving her asylum, thus providing members of her dynasty with the base from which they would eventually return to their throne in Kabul. She died in 1838, just before the British put her husband back on the Afghan throne. Many have attributed the ultimate failure of that enterprise to the absence of her strategic good sense.

The region also has a great tradition of peaceful resistance. In the 1930s, the North-West Frontier, under the Pashtun leader Badshah Khan, became an unlikely center of Gandhian nonviolence against the British Raj. A prominent group of activists called the Khudai Khidmatgars, or Servants of God, drew direct inspiration from Gandhi’s ideas of service, disciplined nonviolence and civil disobedience to defy the colonial authorities. They also championed education, in order to marginalize the influence of the conservative ulema — the religious scholars. As the leading modern writer on the movement, Mukulika Banerjee, has shown, the Khudai Khidmatgars have been virtually erased from the nationalist historiography of post-partition Pakistan.

The fact that all this history surprises us as much as it does is a measure of how far we have allowed the extremists to dominate our images of what it means to be a Muslim in general, and Pashtun in particular. It is certainly true that both sides of the Afghanistan-Pakistan border have been lacerated by violent extremism and misogyny — ever since the United States, the Saudis and Pakistan’s intelligence agency armed religious extremists in Peshawar in the 1980s to take on the Soviet Union. But it should be remembered that the main resistance to extremism has been the local Pashtuns themselves.

We owe it to Malala and many others who share her ideals to refuse to allow the radicals to win the battle of perceptions. It is, and has always been, possible to be a Muslim Pashtun and to embrace nonviolence and a prominent role for women in public affairs. Indeed the greatest weapon we have in the war on terrorism in that region is the courage and the decency of the vast proportion of the people who live there.

William Dalrymple is the author, most recently, of “Return of a King: The Battle for Afghanistan, 1839-42.”