President Barack Obama has confirmed plans to extend the US military presence in Afghanistan beyond 2016, in a shift in policy.
Speaking at the White House, he said the US would keep 5,500 troops in the country when he leaves office in 2017.
Originally all but a small embassy-based force were due to leave by the end of next year.
But the US military says more troops will be needed to help Afghan forces counter a growing Taliban threat.
There are currently 9,800 US troops stationed in Afghanistan. Last week, the top US military commander in Afghanistan, Gen John Campbell, said the US must consider extending its military presence there beyond 2016.
The US forces will be stationed in four locations - in Kabul, Bagram, Jalalabad and Kandahar.
President Obama had previously planned to reduce the number of troops left in Afghanistan to about 1,000 by the time he left office in January 2017.
A statement from the US National Security Council said the change in policy was the "result of an extensive, months-long review", and after Obama had consulted "with his full national security team and our Afghan partners".
"This announcement in no way changes the fact that our combat mission in Afghanistan has ended, and we will continue to undertake only two narrow missions: counterterrorism and training, advising, and assisting our Afghan partners," the statement went on.
Afghan President Ashraf Ghani is expected to publicly welcome the move, as he had been pushing for a slower withdrawal of US troops to allow Afghan forces to be better trained and equipped.
US Gen John Campbell expressed concern last week over the "tenuous security situation" and said an enhanced military presence would be necessary if the Taliban were to be repelled.
He was speaking days after the Taliban briefly seized the northern city of Kunduz - their most spectacular military gain since being ousted from power in 2001.
After the Taliban's surprise attack on Kunduz, Afghan government forces managed to retake control of key areas of the city with the aid of Nato special forces and US air strikes.
But the city's brief capture was seen as a setback for the Afghan authorities under pressure to show they can keep the country secure without the backing of international forces.
The south-eastern city of Ghazni has also seen fierce clashes between Taliban insurgents and US-trained Afghan troops in recent days.
Militant violence has increased across Afghanistan since Nato ended its combat mission there in December 2014, leaving a residual force - mainly US troops - used for training and counter-terrorism operations.
The shift in policy comes at the same time as three separate investigations - by the US, Nato and Afghan authorities - into a US air attack on an MSF-run hospital in Kunduz that killed 22 people.
The US said the bombing was a mistake, and President Obama later apologised.