For starting context of the current situation and past 40+ years of recent history;
Part 1
...
The
Soviet–Afghan War was a conflict wherein insurgent groups (known collectively as the
Afghan mujahideen), as well as smaller
Maoist groups, fought a nine-year
guerrilla war against the
Soviet Army and the
Democratic Republic of Afghanistan government throughout the 1980s, mostly in the Afghan countryside. The Mujahideen were variously backed primarily by the United States, Pakistan, Iran, Saudi Arabia, China, and the United Kingdom; the conflict was a
Cold War-era
proxy war. Between 562,000
[48] and 2,000,000 Afghans were killed and millions more fled the country as refugees,
[52][53][49][50] mostly
to Pakistan and Iran. Between 6.5%–11.5% of Afghanistan's population is estimated to have perished in the conflict. The war caused grave destruction in Afghanistan and is believed to have contributed to the
Soviet collapse and the end of the Cold War, in hindsight leaving a mixed legacy to people in both territories.
[54][55]
The foundations of the conflict were laid by the
Saur Revolution, a 1978
coup wherein
Afghanistan's communist party took power, initiating a series of radical modernization and land reforms throughout the country. These reforms were deeply unpopular among the more traditional rural population and established power structures.
[56] The repressive nature of the "
Democratic Republic",
[57] which vigorously suppressed opposition and executed thousands of political prisoners, led to the rise of anti-government armed groups; by April 1979, large parts of the country were in open rebellion.
[58]
The communist party itself experienced deep internal rivalries between the
Khalqists and
Parchamites; in September 1979,
People's Democratic Party General Secretary
Nur Mohammad Taraki was assassinated under orders of the second-in-command,
Hafizullah Amin, which soured relations with the Soviet Union. With fears rising that Amin was planning to switch sides to the
United States,
[59] the Soviet government, under leader
Leonid Brezhnev, decided to
deploy the
40th Army across the border on 24 December 1979.
[60] Arriving in the capital Kabul, they staged a coup (
Operation Storm-333),
[61] killing General Secretary Amin and installing Soviet loyalist
Babrak Karmal from the rival faction
Parcham.
[58] The Soviet invasion
[nb 1] was based on the
Brezhnev Doctrine.
In January 1980, foreign ministers from 34 nations of the
Organisation of Islamic Cooperation adopted a resolution demanding "the immediate, urgent and unconditional withdrawal of Soviet troops" from Afghanistan.
[65] The
UN General Assembly passed a resolution protesting the Soviet intervention by a vote of 104 (for) to 18 (against), with 18
abstentions and 12 members of the 152-nation Assembly absent or not participating in the vote;
[65][66] only Soviet allies
Angola,
East Germany and Vietnam, along with India, supported the intervention.
[67] Afghan insurgents began to receive massive amounts of support through aid, finance and military training in neighbouring Pakistan with significant help from the United States and United Kingdom.
[68] They were also heavily financed by China and the
Arab monarchies in the Persian Gulf.
[69][15][70] [71] As documented by the
National Security Archive, "the
Central Intelligence Agency (CIA) played a significant role in asserting U.S. influence in Afghanistan by funding military operations designed to frustrate the Soviet invasion of that country. CIA
covert action worked through
Pakistani intelligence services to reach Afghan rebel groups."
[72] Soviet troops occupied the cities and main arteries of communication, while the Mujahideen waged guerrilla war in small groups operating in the almost 80 percent of the country that was outside government and Soviet control, almost exclusively
[73] being the rugged, mountainous terrain of the countryside.
[74][75] The Soviets used their air power to deal harshly with both rebels and civilians, levelling villages to deny safe haven to the Mujahideen, destroying vital irrigation ditches, and laying millions of land mines.
[76][77][78][79]
....
en.wikipedia.org
Of ocurse, this Wiki page goes on for some length ...