Here's a list of key events that preceded the withdrawal of American troops from Kabul.

US President Joe Biden(C) attends the transfer of the remains of fallen service members at Dover Air Force Base in Dover, Delaware, August, 29, 2021, after 13 members of the US military were killed in Afghanistan last week.
US President Joe Biden(C) attends the transfer of the remains of fallen service members at Dover Air Force Base in Dover, Delaware, August, 29, 2021, after 13 members of the US military were killed in Afghanistan last week. (AFP)

The United States descended on Afghanistan and its Taliban government in 2001 in the wake of the September 11 attacks by Al-Qaeda, which had sought sanctuary in the country.

After 20 years of war, the last American troops in the US-led NATO coalition flew out of Afghanistan on early Tuesday morning.

Here is a timeline of key events:

War on terror

On October 7, 2001 - less than a month after the September 11 attacks that killed around 3,000 people in the US - President George W. Bush launches "Operation Enduring Freedom" in Afghanistan.

The ruling Taliban had been sheltering Osama bin Laden and his Al-Qaeda movement, which carried out the 9/11 attacks.

The operation opens a military front in the US "war on terror" and within weeks, US-led forces overthrow the Taliban, in power since 1996.

About 1,300 American soldiers are on the ground by November 2001, rising to almost 10,000 the next year.

READ MORE: American troops leave a war-torn Afghanistan behind

American attention is diverted from Afghanistan when US forces invaded Iraq in March 2003, to oust Saddam Hussein.

The fragmented Taliban and other outfits regroup in their strongholds in southern and eastern Afghanistan and launch an insurgency.

In 2008, the US command in Afghanistan calls for more manpower.

Bush sends additional soldiers, bringing the total to 48,500 US troops deployed.

More boots on ground

In 2009, Barack Obama - elected president after a campaign that promised to end the Iraq and Afghanistan wars - boosts the US presence to around 68,000. In December, he sends another 30,000 troops.

The objective is to stymie the growing Taliban insurgency and strengthen Afghan institutions.

By 2010 about 150,000 foreign soldiers are deployed in Afghanistan, of which 100,000 are American.

Bin Laden killed

Osama bin Laden is killed on May 2, 2011 in a US special forces operation in Pakistan.

The NATO alliance ends its combat mission in Afghanistan in 2014, but around 12,500 foreign soldiers - of which 9,800 are American - remain to train Afghan troops and conduct anti-terrorist operations.

Amid a spreading Taliban insurgency, security in the country deteriorates and a branch of Daesh terrorist group also becomes active in 2015.

President Donald Trump scraps any timetables for a US pullout, and re-commits thousands more soldiers in August 2017.

But deadly attacks multiply, especially against Afghan forces and the US dramatically steps up air strikes.

Doha talks

In 2018, Washington and Taliban representatives discreetly open talks in Doha focused on slashing the American military footprint in Afghanistan.

In return, Washington demands that the Taliban prevent the country from being used as a haven for militant groups.

On February 29, 2020 the US and Taliban sign a historic deal paving the way for the withdrawal of all foreign forces from Afghanistan by May 2021.

The insurgents in return offer some security guarantees, and agree to hold peace talks with the Afghan government.

Those begin in September, but violence surges. 

Taliban comes into power

Troop numbers by the end of Trump's presidency in January 2021 fall to 2,500 as support for military action wanes.

At the end of April, NATO begins a concurrent withdrawal of its mission involving 9,600 soldiers.

President Joe Biden says he will stick to the agreement with the Taliban, but delays the drawdown deadline until September 11.

READ MORE: Taliban need to 'earn' legitimacy and support, says Blinken

Officials on June 2 announce the departure of all US and NATO troops from Bagram, Afghanistan's biggest air base.

Biden on July 8 says the US retreat will be completed on August 31.

On August 15, the Taliban sweep into Kabul, with tens of thousands of Afghans and foreigners rushing to the airport in a desperate bid to scramble onto evacuation flights.

More than 123,000 people are airlifted out of Kabul.

Just hours before the August 31 deadline, the last of the thousands of American troops fly out.

Source: TRTWorld and agencies