The US will continue to support Afghanistan after withdrawing all US troops, but not "militarily," President Joe Biden has pledged.
"It is time to end America's longest war," he said in a speech from the White House room where US airstrikes there were first declared in 2001.
The pull-out is to coincide with the 20th anniversary of the 11 September 2001 terror attacks, officials say.
At least 2,500 US troops are part of the 9,600-strong Nato Afghan mission.
The number of US troops on the ground in Afghanistan fluctuates, and US media report the current total is closer to 3,500.
US and Nato officials have said the Taliban, a hardline Islamist movement, have so far failed to live up to commitments to reduce violence in Afghanistan.
In Kabul, Afghan officials say they will continue peace talks in preparation for the withdrawal.
Afghan President Ashraf Ghani tweeted that he had spoken on the phone with Mr Biden on Wednesday, and that the country "respects the US decision and we will work with our US partners to ensure a smooth transition".
He added that Afghanistan's defence forces "are fully capable of defending its people and country".
What did Biden say?
"We cannot continue the cycle of extending or expanding our military presence in Afghanistan hoping to create the ideal conditions for our withdrawal, expecting a different result," said Mr Biden, the fourth president to oversee the war.
"While we will not stay involved in Afghanistan militarily, our diplomatic and humanitarian work will continue," he continued, adding: "We will continue to support the government of Afghanistan."
Mr Biden also pledged to continue providing assistance to Afghan defence and security forces - including 300,000 personnel, who he says "continue to fight valiantly on behalf of their country and defend the Afghan people, at great cost".
He also paid his respects to the victims of the 11 September 2001 attack which triggered the US invasion of Afghanistan.
"We went to Afghanistan because of a horrific attack that happened 20 years ago," he said. "That cannot explain why we should remain there in 2021."
"We have to focus on the challenges that are in front of us," said Mr Biden, citing the threat of cyber attacks and rising tensions with China.
"We already have service members doing their duty in Afghanistan today whose parents served in the same war," he added.
"We have service members who were not yet born when our nation was attacked on 9/11. War in Afghanistan was never meant to be a multigenerational undertaking."
Later on Wednesday, Mr Biden will visit Arlington National Cemetery, where some of the 2,488 US troops who died fighting in Afghanistan are buried.
What is the withdrawal timeline?
Mr Biden's plan pushes back the 1 May deadline agreed to by the Trump White House.
The deal signed in February 2020 said the US and its Nato allies would withdraw all troops by May 2021 if the Taliban upheld its promises, including not allowing al-Qaeda or other militants to operate in areas it controlled and proceeding with national peace talks.
Although the group stopped attacks on international forces as part of the historic agreement, it has continued to fight the Afghan government. Last month, the Taliban threatened to resume hostilities against foreign troops still in the country on 1 May.
Solid political ground - for now
Last year Donald Trump set in motion a full US withdrawal from Afghanistan. This week, Joe Biden - who as Barack Obama's vice-president opposed an ongoing large US presence in the nation - pledged to see the process to its final resolution.
That his administration will miss the Trump-set deadline of 1 May has been overshadowed by the symbolism of Biden's new deadline, 11 September, the 20th anniversary of the attack that instigated US entry into Afghanistan.
Trump's actions have insulated Biden from significant criticism so far, even from conservative hawks. Senate minority leader Mitch McConnell called Biden's decision a "grave mistake," but others - like Texas Senator Ted Cruz - have voiced support.
While the short-term political downside of withdrawing the 3,500 remaining US soldiers appears minimal, Biden's move is not without risk. If the Taliban takes power and cracks down on women's rights, or if the nation once again becomes a haven for extremist militants, the American public could hold Biden responsible - and today's critics will have new ammunition.
In the meantime, however, Biden will claim credit for ending "America's longest war" and focusing the nation's efforts on domestic challenges. He will do so on solid political ground - for now.
On Wednesday, US CIA Director William Burns said in a senate hearing that military capabilities in the region would be diminished once the US leaves.
"There is a significant risk once the US military and the coalition militaries withdraw," he said, adding that the US will still "retain a suite of capabilities" to counter extremist threats.
On Tuesday, a senior US official warned that the Taliban "will be met with a forceful response" if they attack US troops during the pull-out phase.
What are Afghans saying?
Abdullah Abdullah, head of the nation's High Council for National Reconciliation, said on Wednesday that the news of foreign troops withdrawing means "we need to find a way to co-exist", Reuters news agency reported.
"We believe that there is no winner in Afghan conflicts and we hope the Taliban realise that too," he said.
Afghans across the country have told the BBC's Afghan service that they are alarmed by the news.
"I do not think conditions are suitable for withdrawal," says Roeena Usmani, who lives in the western Herat province bordering Iran.
"The international community has not yet fulfilled their commitments, there is talk of the Taliban returning to power-sharing."
"We are concerned that we could lose all the achievements of the last 20 years, particularly for women," she continues. "There should be guarantees that we should not return to the dark days of 20 years ago."
Mohammad Askar, a resident of Mazar-e Sharif in northern Afghanistan, said: "If American troops want to leave Afghanistan they should do so with a plan.
"If not, I fear Afghanistan will return to civil war."
Weyar, a resident of the northern Baghlan province, said the US "should go after reaching agreement with all stakeholders, including the Taliban".
"Otherwise Afghanistan may plunge into war, which will be disastrous not only for Afghanistan but the whole world."
US military involvement in Afghanistan
October 2001: US-led bombing of Afghanistan begins following the 11 September attacks on the United States
February 2009: Nato countries pledge to increase military and other commitments in Afghanistan after US announces dispatch of 17,000 extra troops
December 2009: US President Barack Obama decides to boost US troop numbers in Afghanistan by 30,000, bringing total to 100,000. He says US will begin withdrawing its forces by 2011
October 2014: The US and UK end their combat operations in Afghanistan
March 2015: President Obama announces his country will delay its troop withdrawal from Afghanistan, following a request from President Ashraf Ghani
October 2015: President Obama announces that 9,800 US troops will remain in Afghanistan until the end of 2016, backtracking on an earlier pledge to pull all but 1,000 troops from the country
July 2016: President Obama says 8,400 US troops will remain in Afghanistan into 2017 in light of the "precarious security situation". Nato also agrees to maintain troop numbers and reiterates a funding pledge for local security forces until 2020
August 2017: US President Donald Trump says he's sending more troops to fight a resurgent Taliban
September 2019: Protracted peace talks between the Taliban and the US break down
February 2020: After months of on-off talks, the US signs a troop withdrawal agreement in Doha with the Taliban