After 20 years of war, foreign forces are pulling out of Afghanistan following a deal between the US and the Taliban militants they removed from power back in 2001.
The conflict has killed tens of thousands of people and displaced millions.
The Taliban have pledged not to allow Afghanistan to become a base for terrorists who could threaten the West.
But the country’s hardline former rulers have quickly gained territory in recent weeks from Afghan army soldiers, who are now being left to protect a fragile government.
The Taliban also made a pledge for national peace talks, but many fear a worsening civil war remains a far more likely outcome.
Nevertheless, Joe Biden, the fourth US president to oversee what has become America’s longest-ever war – one costing hundreds of billions of dollars – has set a symbolic date of 11 September 2021 for full withdrawal.
Why did the US fight a war in Afghanistan and why did it last so long?
Back in 2001, the US was responding to the 9/11 attacks on New York and Washington, in which nearly 3,000 people were killed. Officials identified Islamist militant group al-Qaeda, and its leader Osama Bin Laden, as responsible.
Bin Laden was in Afghanistan, under the protection of the Taliban, the Islamists who had been in power since 1996.
When they refused to hand him over, the US intervened militarily, quickly removing the Taliban and vowing to support democracy and eliminate the terrorist threat.
The militants slipped away and later regrouped.
Nato allies had joined the US and a new Afghan government took over in 2004 but deadly Taliban attacks continued. President Barack Obama’s “troop surge” in 2009 helped push back the Taliban but it was not long term.
In 2014, at the end of what was the bloodiest year since 2001, Nato’s international forces ended their combat mission, leaving responsibility for security to the Afghan army.
That gave the Taliban momentum and they seized more territory.
Peace talks between the US and the Taliban started tentatively, with the Afghan government pretty much uninvolved, and the agreement on a withdrawal came in February 2020 in Qatar.
The US-Taliban deal did not stop the Taliban attacks – they switched their focus instead to Afghan security forces and civilians, and targeted assassinations. Their areas of control grew.
Twenty years of conflict in Afghanistan – what happened when?
From 9/11, to intense fighting on the ground, and now full withdrawal of US-led forces, here’s what happened.
Al-Qaeda, led by Osama Bin Laden in Afghanistan, carries out the largest terror attack ever conducted on US soil.
Four commercial airliners are hijacked. Two are flown into the World Trade Centre in New York, which collapses. One hits the Pentagon building in Washington, and one crashes into a field in Pennsylvania. Nearly 3,000 people are killed.
First air strikes
A US-led coalition bombs Taliban and al-Qaeda facilities in Afghanistan. Targets include Kabul, Kandahar and Jalalabad.
The Taliban, who took power after a decade-long Soviet occupation was followed by civil war, refuse to hand over Bin Laden. Their air defences and small fleet of fighter aircraft are destroyed.
Fall of Kabul
The Northern Alliance, a group of anti-Taliban rebels backed by coalition forces, enters Kabul as the Taliban flee the city.
By the 13 November 2001, all Taliban have either fled or been neutralised. Other cities quickly fall.
After protracted negotiations at a “loya jirga” or grand assembly, the new Afghan constitution is signed into law. The constitution paves the way for presidential elections in October 2004.
Hamid Karzai becomes president
Hamid Karzai, the leader of the Popalzai Durrani tribe, becomes the first president under the new constitution. He serves two five-year terms as president.
UK troops deployed to Helmand
British troops arrive in Helmand province, a Taliban stronghold in the south of the country.
Their initial mission is to support reconstruction projects, but they are quickly drawn into combat operations. More than 450 British troops lose their lives in Afghanistan over the course of the conflict.
US President Barack Obama approves a major increase in the number of troops sent to Afghanistan. At their peak, they number about 140,000.
The so-called “surge” is modelled on US strategy in Iraq where US forces focussed on protecting the civilian population as well as killing insurgent fighters.
Osama Bin Laden killed
The leader of al-Qaeda is killed in an assault by US Navy Seals on a compound in Abbottabad in Pakistan. Bin Laden’s body is removed and buried at sea. The operation ends a 10-year hunt led by the CIA. The confirmation that Bin Laden had been living on Pakistani soil fuels accusations in the US that Pakistan is an unreliable ally in the war on terror.
Death of Mullah Omar
The founder of the Taliban, Mullah Mohammed Omar, dies. His death is kept secret for more than two years.
According to Afghan intelligence, Mullah Omar dies of health problems at a hospital in the Pakistani city of Karachi. Pakistan denies that he was in the country.
Nato ends combat operations
At a ceremony in Kabul, Nato ends its combat operations in Afghanistan. With the surge now over, the US withdraws thousands of troops. Most of those who remain focus on training and supporting the Afghan security forces.
The Taliban launch a series of suicide attacks, car bombings and other assaults. The parliament building in Kabul, and the city of Kunduz are attacked. Islamic State militants begin operations in Afghanistan.
Death toll announcement
Afghan President Ashraf Ghani says more than 45,000 members of his country’s security forces have been killed since he became leader in 2014. The figure is far higher than previously thought.
US signs deal with Taliban
The US and the Taliban sign an “agreement for bringing peace” to Afghanistan, in Doha, Qatar. The US and Nato allies agree to withdraw all troops within 14 months if the militants uphold the deal.
Date for final withdrawal
US forces are scheduled to withdraw from Afghanistan by 11 September 2021, exactly 20 years since 9/11. There are strong indications that the withdrawal may be complete before the official deadline.
Who are the Taliban?
They emerged in the civil war that followed the withdrawal of Soviet troops in 1989, predominantly in the south-west and the Pakistan border areas.
They vowed to fight corruption and improve security, but also followed an austere form of Islam.
By 1998, they had taken control of almost all of the country.
Find out more on the Afghan conflict 2001-2021
They enforced their own hardline version of Sharia, or Islamic law, and introduced brutal punishments. Men were made to grow beards and women had to wear the all-covering burka. TV, music and cinema were banned.
After their overthrow they regrouped in Pakistani border areas.
With up to 85,000 full-time fighters, they are thought to be stronger now than at any point since 2001.
How costly has the war been?
In terms of lives lost, it is obviously not easy to say exactly. The number of coalition casualties is much better recorded than Taliban and Afghan civilians.
Research by Brown University estimates losses in the Afghan security forces at 69,000. It puts the number of civilians and militants killed at about 51,000 each.
More than 3,500 coalition soldiers have died since 2001 – about two-thirds of them Americans. More than 20,000 US soldiers have been injured.
According to the UN, Afghanistan has the third-largest displaced population in the world.
Since 2012, some five million people have fled and not been able to return home, either displaced within Afghanistan or taking refuge in neighbouring countries.
Brown University research also puts the US spending on the conflict – including military and reconstruction funds in both Afghanistan and Pakistan – at $978bn (£706bn) up to 2020.
What could happen next?
The obvious question is, will the Taliban take over the country again?
President Biden has expressed confidence that the militants will not topple the government in Kabul.
But one US intelligence assessment in June concluded it could fall within six months of the military departure.
By early August the Taliban were in control of about half the country, according to research by the BBC and others.
The Afghan government disputed some of the militants’ territorial claims – fierce fighting was going on in a number of key cities, and several were in the hands of the militants.
The US says it will keep 650 to 1,000 troops to guard the US embassy, Kabul airport, and other key government installations. The Taliban have said any remaining troops could be targeted.
The other major fear is the country once again becoming a training ground for terrorism.
Taliban officials insist that they will fully adhere to the deal and prevent any group from using Afghan soil as a base for attacks against the US and its allies.
They say they aim only to implement an “Islamic government” and will not pose a threat to any other country.
But many analysts say the Taliban and al-Qaeda are inseparable, with the latter’s fighters heavily embedded and engaged in training activity.
It is important also to remember that the Taliban are not a centralised and unified force. Some leaders may want to keep the West muted by not stirring up trouble but hardliners may be reluctant to break links to al-Qaeda.
Just how powerful al-Qaeda is and whether it could now rebuild its global network is also unclear.
Then there is the regional branch of the Islamic State group – ISKP (Khorasan Province) – which the Taliban oppose.
Like al-Qaeda, ISKP has been degraded by the US and Nato but could use the post-withdrawal period to regroup.
Its fighter numbers could be only between a few hundred and 2,000 but it may try to gain footholds in Kazakhstan, Kyrgyzstan and parts of Tajikistan, which could be a serious regional concern.