The September 11, 2001 attacks on the United States set off a series of events that would see Washington â€“ in just a month â€“ begin the longest war in the countryâ€™s history.
Twenty years later, the US will mark the anniversary of the attacks less than two weeks after completing a chaotic withdrawal from the now Taliban-controlled country.
The 20-year conflict left about 69,000 Afghan security forces and at least 51,000 Afghan civilians dead, according to research by Brown University. About 2,500 members of the US military and 1,144 members of allied-NATO militaries died during the fighting.
Below is a timeline of how events unfolded.
September 11,Â 2001: US attacked
Nineteen members of al-Qaeda, a group granted sanctuary in by Taliban-controlled Afghanistan, hijack four commercial airliners in the US.
Two of the planes are flown into the World Trade Center in New York City, collapsing both towers.
One plane is flown into the Pentagon, the seat of the US Department of Defense, in Virginia.
The fourth plane crashes into a field in Pennsylvania, after passengers on board hearing of the other attacks, storm the cockpit.
A total of 2,977 people were killed in the attacks.
September 18, 2001: AUMF approved
Then-President George W Bush signs the 2001 Authorisation of Use of Military Force (AUMF).
The resolution, which was passed by Congress with only one legislator objecting, legally permits the US president, without further congressional approval, to use military action against a wide array of people or groups that â€œplanned, authorised, committed, or aided the terrorist attacks that occurred on September 11, 2001 or harbored such organizations or personsâ€.
October 7, 2001: â€˜Enduring Freedomâ€™ launched
Less than a month after the September 11 attacks, US President George W Bush launches â€œOperation Enduring Freedomâ€ in Afghanistan, after the Taliban refuses to hand over al-Qaeda leader Osama bin Laden.
In a matter of weeks, the US-led forces overthrow the Taliban, which had been in power since 1996.
Apart from air raids, the US also gives backing to the Afghan Northern Alliance, which had been fighting the Taliban, contributing paramilitary teams from the CIA and special forces.
Some 1,000 American soldiers are deployed on the ground in November, rising to 10,000 the year after.
April 17, 2002: Transitional Afghan govt
A transitional government led by Hamid Karzai is established in Kabul.
US Congress approves $38bn in spending as part of Bushâ€™s plan to rebuild Afghanistan.
October 10, 2002: Iraq AUMF approved
Congress passes the 2002 Iraq AUMF after the Bush administration warns the Baghdad is developing â€œweapons of mass destructionâ€.
Bush signs the resolution into law on October 16.
The resolution sets the US on track for the invasion of Iraq, although no evidence would be found to substantiate the Bush administrationâ€™s claims.
2003-2008: Taliban regroups, Bush sends more troops
Attention is diverted from Afghanistan as US forces in 2003 mount an invasion of Iraq.
As attention turns to Iraq, the Taliban and other armed groups regroup in their strongholds in the south and east of Afghanistan, from where they can easily travel to and from Pakistani tribal areas.
In 2008, the US command on the ground calls for more manpower to carry out an effective strategy against the Taliban.
Bush agrees to send additional soldiers and by mid-2008 there are 48,500 US troops in the country.
2009: Number of soldiers peaks under Obama
In 2009, in the first months of the presidency ofÂ Barack ObamaÂ â€“ elected on campaign promises to end the two wars in Iraq and Afghanistan â€“ there is a surge in the number of American soldiers in Afghanistan to about 68,000.
In December, Obama raises the strength of US forces in Afghanistan to approximately 100,000.
The objective, the US says, is to halt the Taliban militarily and to strengthen Afghan institutions.
In announcing the increase, Obama also set a deadline, saying US forces would begin to reduce US force numbers in 2011.
May 2, 2011: Bin Laden killed in Pakistan
Al-Qaeda leader Osama bin Laden, who the US has identified as the mastermind behind the 9/11 attack, is killed on May 2, 2011, during an operation by US special forces in Pakistan, where he is in hiding.
June 2011: Obama announces troop withdrawal
Obama announces the US will begin withdrawing troops from Afghanistan, as the first attempts to negotiate between the US, Taliban and the Afghan government begin.
By December, the US completely withdraws troops from Iraq.
2014: End of Afghanistan combat operations
In September 2014, Afghanistan signs a bilateral security accord with the US and a similar agreement with NATO: 12,500 foreign soldiers, of which 9,800 are Americans, will remain in the country in 2015, after the end of the NATO combat mission at the end of 2014.
From the beginning of 2015, American troops will be charged with two missions: â€œanti-terroristâ€ operations against al-Qaeda and training Afghan forces.
In late December, the NATO combat mission ends, and is replaced by an assistance mission dubbed, â€œResolute Supportâ€.
However, the security situation deteriorates.
2015: US bombs MSF clinic
On October 3, 2015, at the height of combat between armed groups and the Afghan army, backed by NATO special forces, a US air raid bombs a hospital run by Doctors Without Borders ( Medecins Sans Frontiers, MSF) in northern Kunduz province, killing 42, including 24 patients and 14 members of the NGO.
July 6, 2016: Obama slows withdrawal
Obama again slows down the pace of US troop withdrawal, saying that 8,400 US troops will remain in Afghanistan into 2017.
2017: Trump increases troops
On February 1, 2017, a US government report says that losses of Afghan security forces have climbed by 35 percent in 2016 compared with the previous year.
On February 9, the US general in command of the NATO forces, General John Nicholson, warns that he needs thousands more troops, telling Congress: â€œI believe weâ€™re in a stalemate.â€
On August 21, newly elected President Donald Trump clears the way for the deployment of thousands more US troops to Afghanistan in his first formal address.
Trump later deploys about 3,000 more troops to Afghanistan, bringing the total US troops in the country to about 14,000.
January 28, 2019: US, Taliban agree on â€˜frameworkâ€™
US officials announce negotiators in Doha, Qatar and a Taliban delegation have agreed in principle to a â€œframeworkâ€ for an eventual US withdrawal.
Under the framework, which was established in talks that did not include the Afghan government, the Taliban would guarantee the territory they controlled would not become â€œa platform for international terrorist groups or individualsâ€ in exchange for peace talks with the Taliban and Afghan government.
February 29, 2020: US, Taliban reach withdrawal agreement
The Taliban and the Trump administration reach an agreement for US troops to withdraw by May 1, 2021, in exchange for stopping attacks against US forces and cutting ties with al-Qaeda.
January 15, 2021: Trump draws down troops
In its final days in office, the Trump administration announces that US forces in Afghanistan have been reduced to 2,500.
April 14, 2021: Biden continues withdrawal
President Joe Biden says he will continue with Trumpâ€™s withdrawal agreement, but pushes back the deadline.
He says all US troops will be out of Afghanistan by September 11, 2021 â€“ the 20th anniversary of the 9/11 attacks.
July 8, 2021: Biden moves up deadline
Two days after US forces leave the Bagram Airfield, its largest military installation in Afghanistan, Biden announces that US troops will completely withdraw from Afghanistan by August 31.
He says recent advances by the Taliban will not change the withdrawal timeframe.
August 6, 2021: Taliban offensive
The Talibanâ€™s lightning-fast advance, launched in May, sees the group on August 6 take its first provincial capital, Zaranj, since the offensive began.
At least 17 more provinces fall to the Taliban in the coming days, as the group poises itself to take Kabul.
August 15, 2021: Taliban enter Kabul
The Taliban enter Kabul with no resistance as President Ashraf Ghani flees the country.
The speed of the fall of the Afghan government upends even the least optimistic assessments from Western intelligence agencies, and sends countries scrambling to evacuate citizens and vulnerable Afghans through the Kabul airport, which comes under US military control.
August 26, 2021: ISKP attacks airport
As chaotic evacuation efforts continue, The Islamic State in Khorasan Province, or ISKP (ISIS-K), attacks the Kabul airport in a bombing that kills nearly 200 Afghans and 13 members of the US military.
The attack proves one of the deadliest for US forces since they first entered Afghanistan.
A resulting US drone raid kills several civilians, including children, in Kabul.
August 30, 2021: All US Troops leave Afghanistan
The Pentagon announces that all US troops have left Afghanistan â€“ With the last plane lifting off just before midnight, ahead of the August 31 deadline.
At least 100 US citizens remain in Afghanistan, as well as an untold number of Afghans who worked for the US government.
The Taliban seize Kabul airport, which has not been operational since, as the US moves its Afghanistan diplomatic team to Doha, Qatar.