US forces have left Bagram airbase, north of Kabul, effectively completing its military campaign in Afghanistan ahead of the official end date.
President Biden has said he wants US troops out of Afghanistan by 11 September this year.
We've been looking at how much the US has spent in Afghanistan since the war began.
What forces did the US send?
About 650 US troops are expected to stay in Afghanistan to provide security for diplomats after the main withdrawal is completed, according to the Associated Press.
The US invaded in October 2001 to oust the Taliban, whom they said were harbouring Osama Bin Laden and other al-Qaeda figures linked to the 9/11 attacks.
US troop numbers grew as Washington poured in billions of dollars to fight a Taliban insurgency and fund reconstruction, but started falling after 2011.
Last year, there 4,000 US troops, which had shrunk to about 2,500 by January this year.
And there are also significant numbers of private security contractors working for the US in Afghanistan. This included as of the last quarter of 2020 more than 7,800 US citizens, according to US Congress research.
US media reports say most private contractors are due to pull out as part of the overall withdrawal by Washington.
As the US military shifted its focus away from offensive operations and concentrated more on training up Afghan forces, costs fell sharply.
Between 2010 to 2012, when the US for a time had more than 100,000 soldiers in the country, the cost of the war grew to almost $100bn a year, according to US government figures.
By 2018 annual expenditure was around $45bn, a senior Pentagon official told the US Congress that year.
According to the US Department of Defense, the total military expenditure in Afghanistan (from October 2001 until September 2019) had reached $778bn.
In addition, the US state department - along with the US Agency for International Development (USAID) and other government agencies - spent $44bn on reconstruction projects.
That brings the total cost - based on official data - to $822bn between 2001 and 2019, but it doesn't include any spending in Pakistan, which the US uses as a base for Afghan-related operations.
According to a Brown University study in 2019, which has looked at war spending in both Afghanistan and Pakistan, the US had spent around $978bn (their estimate also includes money allocated for the 2020 fiscal year).
The study notes that it is difficult to assess the overall cost because accounting methods vary between government departments, and they also change over time, leading to different overall estimates.
Where has the money gone?
The bulk of the money spent in Afghanistan has been on counter-insurgency operations, and on the needs of US troops such as food, clothing, medical care, special pay and benefits.
Before US troops withdrew from the Bagram airbase, US Central Command said it destroyed nearly 16,000 pieces of equipment.
Official data shows that since 2002, the US has also spent about $143.27bn on reconstruction activities in Afghanistan.
More than half ($88.32bn) was spent on building up Afghan security forces, including the Afghan National Army and police force.
Nearly $36bn has been allocated for governance and development, while smaller amounts were also allocated for anti-drug efforts and for humanitarian aid.
Some of this money has been lost to waste, fraud and abuse over the years.
In a report to the US Congress in October 2020, the watchdog responsible for the oversight of reconstruction efforts in Afghanistan estimated that about $19bn had been lost this way between May 2009 and December 31, 2019.
What about the human cost?
Since the war against the Taliban began in 2001, US forces have suffered more than 2,300 deaths and around 20,660 soldiers injured in action.
US casualty figures are dwarfed by the loss of life among Afghan security forces and civilians.
President Ghani said in 2019 that more than 45,000 members of the Afghan security forces had been killed since he became president five years earlier.
Brown University's research in 2019 estimated the loss of life amongst the national military and police in Afghanistan to be more than 64,100 since October 2001, when the war began.
And according to the United Nations Assistance Mission in Afghanistan (Unama), nearly 111,000 civilians have been killed or injured since it began systematically recording civilian casualties in 2009.