The Soviet invasion of Afghanistan 40 years ago kicked off decades of war that endured long after the Red Army´s retreat, which ended on February 15, 1989.

Here is a timeline.

1979-1989: Soviet occupation

In December 1979, at the height of the Soviet-US Cold War, Moscow invades the country — which is poor and mountainous, but also strategically situated — to prop up a communist regime.

It faces fierce resistance from Afghan mujahideen fighters backed by the United States and others.

Moscow eventually withdraws after a decade of fighting.

1992-1996: Civil war

The fall of Mohammad Najibullah´s communist government in 1992 unleashes a bloody power struggle that kills nearly 100,000 people in two years and partly destroys the capital, Kabul.

From 1994 the  Taliban movement begin to emerge in the south.

1996-2001: Taliban in power

The Taliban, led by Mullah Mohammad Omar, seize power in 1996 and install a regime based on their hardline interpretation of Shariah law. They forbid women from working, close girls´ schools, and ban music and other entertainment.

Under severe United Nations sanctions, the regime becomes close to the al Qaeda network and shelters its leader, Saudi national Osama bin Laden.

2001: US-led invasion

In October 2001 the United States leads an invasion of Afghanistan in retaliation for the September 11 attacks on Washington and New York blamed on al Qaeda.

Washington and its NATO allies drive out the Taliban regime and bring Hamid Karzai to power, funnelling in billions of dollars of aid to rebuild the war-ravaged country.

They deploy up to 150,000 soldiers to help the government assert control and bring security.

The Taliban go into hiding or flee to neighbouring countries and then launch an insurgency against Kabul and NATO.

2014: NATO withdraws

NATO pulls out its International Security Assistance Force (ISAF) combat troops at the end of 2014, with the Taliban insurgency raging.

Some NATO soldiers remain to carry out anti-terrorist operations and train Afghan forces.

The Taliban continue to make gains, while carrying out major deadly attacks, as the Deash group begins to make inroads in Afghanistan in 2015.

2018-2019: Peace talks

In late 2018 US President Donald Trump says he is withdrawing half of the 14,000 US soldiers stationed in Afghanistan, though officials caution they have received no order to begin drawdown plans.

Washington steps up negotiations with the Taliban to end the conflict, with both the militants and US officials touting “progress” after talks culminate in a six-day meeting in Qatar in January.

Afghan hopes for peace are tempered by fears the US could withdraw before a lasting deal is reached with Kabul, however.

Russia and Iran also hold talks with the militants.