From Afghanistan: A Cultural and Political History, by Thomas Barfield (Princeton U. Press, 2010), Kindle pp. 255-257:
The Taliban was a cross-border movement led by Afghan Pashtuns trained in Deobandi madrasas in Pakistan. Its ideological roots lay there, and its Afghan leaders had close ties with religious parties in Pakistan. The madrasas had grown at a tremendous rate in Pakistan under Zia al Haq, attracting a large number of Afghan refugee boys by offering free room and board along with education. During the Soviet war, the schools’ graduates joined the mujahideen to fight in Afghanistan in defense of Islam through the existing Peshawar party structure. But because the civil war now pitted Muslim against Muslim, the Taliban movement’s goal shifted to ending the disorder while also reforming Afghanistan’s religious and cultural practices by creating a pure Islamic state along Salafist lines. This ambition was shared by the religious parties within Pakistan, but the disorder in Afghanistan gave the Taliban a better chance of achieving it.
The Taliban was unlike other Afghan political movements not only in the exclusively clerical origin of its leaders but in the refugee origins of its followers too. The Soviet war lasted for so long and the refugee flow into neighboring countries was so great that over time they created a new class of people: refugee Afghans born in Pakistan who had never seen the country or experienced life there. Refugee camps are notorious hotbeds for radical movements of all types because they are generally poor, provide few opportunities for young people, and are under the control of political factions that manipulate their populations. The hope of recovering a lost homeland is a particularly powerful ideal, but as time passes the view of this homeland becomes more and more mythical because refugee children know of it only by hearsay. The past is idealized because the present is so miserable and the future is so uncertain. Groups with extreme messages, whether their ideologies are political, ethnic, or religious, galvanize their followers not only with the visions of reclaiming a lost homeland but also of then transforming it. Refugees in Afghanistan did better than most. They experienced a tactical victory when the Soviets withdrew and in theory could return to their homeland.
But the fighting among the mujahideen foreclosed that option for most. Even when the refugees did return, their homeland was not what they had known when they left it. Although poor before the war, the Afghan economy at least functioned, and there was general security for life and property. Now there was none. The mujahideen, who had been heroes in the anti-Soviet jihad, lost respect when they became mere factions engaged in self-interested and violent struggles for power with other similar groups. The Taliban drew on this discontent in two ways. First, they recruited men who had been too young to participate in the anti-Soviet war and gave them a chance to participate in a new type of jihad—one that would bring a “truer version” of Islam to Afghanistan. Jihad had been the focal experience for young men throughout the Soviet war, and a new generation of refugee youths was looking for a goal that was equally as idealistic. That the Taliban’s view of Islam was far more radically reactionary than any existing in Afghanistan previously meant little to people who had nothing to compare it with. For them it was far easier to imagine an ideal Afghan way of life, and to enforce it on others, because they drew their lessons from religious schools rather than the give-and-take of everyday life. Their hostility toward women may well have stemmed from being removed from their families and female relations at an early age to grow up in all-male religious schools. Second, the Taliban drew on the discontent of the population living in areas where chaos prevailed. For them, any ideology or regime that could bring about stability was preferable to the status quo.