Ninety-nine per cent of Afghans are Muslims, and the current constitution, adopted in 2004, defines Afghanistan as an "Islamic Republic". It also stipulates that Islam is the "the religion of the state" and that "no law can be contrary to the beliefs and provisions of the sacred religion of Islam". Popular Islam in Afghanistan has very strong, though not publicly displayed, Sufi undercurrents, with the Naqshbandiya and Qaderiya the most influential tariqa (orders). Going beyond the provisions of the 1964 constitution that gave the Hanafi school of Sunni Islam dominant status, it establishes equal rights for the Shia minority for the first time. As the constitution prohibits "any kind of discrimination", it also gives equal rights to non-Muslim minorities. It further stipulates, "Followers of other religions are free to exercise their faith and perform their religious rites within the limits of the provisions of law". These legal provisions do not always translate into practice.
Afghan society before the Soviet occupation was religiously conservative, with a few liberal urban enclaves and little Islamist influence. However, throughout the 20th century, repeatedly top-down and violently enforced modernisation by various Afghan governments provoked armed resistance from conservative tribal actors and the Islamic clergy. The first such instance concerned the 1920s reforms of King Amanullah, and similar resistance befell Soviet-backed regimes between 1978-92. In general however, the clergy – the mullahs, who were often uneducated and outsiders in many communities, and the better-educated ulema (higher-ranking Islamic scholars; singular: alim) – remained politically weak and only of local importance. Their monopolistic grip on education had largely been broken by Amanullah's reforms. Beginning in the mid-1950s, Islamists had a marginal presence at the few universities and some rural madrassas. They were repressed under the monarchy (until 1973), the Republic (1973-78) and the leftist regimes (1978-92).
Increasing polarisation over the 1960s and 1970s between conservative and leftist reformist forces culminated in the takeover by the People's Democratic Party of Afghanistan (PDPA) in 1978, and the Soviet military intervention on their behalf in the following year which led to a mobilisation of the Afghan Islamists. With Afghanistan now a hot spot in the Cold War, they took over leadership of the anti-Soviet resistance, supported by the West, Arab regimes and foreign extremists. Support to the country's Islamists was channelled through the influence of Pakistan's Islamist military dictator, General Muhammad Zia-ul-Haq (ruled 1978-88). When in 1981 he decided to support only seven Islamist mujahedin groups, other groups that had participated in the resistance were marginalised and cut off from Pakistani supplies. This allowed the mujahedin to reinterpret the national liberation struggle more narrowly in religious terms, as a 'jihad'.