Trump had previously criticised US involvement in the 16-year conflict
Donald Trump has laid the way for an increase in US troops in Afghanistan, vowing he would "fight to win" America's longest war.
The president said his original instinct was to pull US forces out but he now feared such a move would leave a vacuum for terrorists to fill.
Mr Trump did not specify how many more troops would be added and gave no timeline for ending the US presence in Afghanistan.
But officials said he had signed off on Defense Secretary James Mattis' plans to send about 4,000 more to add to the 8,400 now deployed.
In a televised address, Mr Trump also put pressure on Pakistan, India and NATO allies to step up their own commitment in the country.
Speaking at a military base near Washington, he said: "Nearly 16 years after the September 11 attacks...the American people are weary of war without victory and nowhere is this more evident than with the war in Afghanistan."
However he said the consequences of a rapid exit are "both predictable and unacceptable".
"A hasty withdrawal would create a vacuum that terrorists...would instantly fill just as happened before September 11," he said.
At its peak in 2010/11, the US had roughly 100,000 troops in Afghanistan but this number has dropped to roughly 8,400 now, as the country battles a resurgent Taliban.
Mr Trump said that, while the US would continue to support the Afghan Government, it was up to the Afghan people to "take ownership of their future".
But there are widespread doubts about the Afghans' ability to do that - even now the government controls only half the country.
Afghanistan's security forces are seen as incapable of stopping the advance of the Taliban and of an Islamic State searching for new havens as it loses territory in Syria and Iraq.
"The stronger the Afghan security forces become, the less we will have to do," Mr Trump said.
"We want them to succeed but we will no longer use American military might to try to construct democracies in far off lands. We are not nation building again - we are killing terrorists."
During his presidential campaign, Mr Trump criticised his country's involvement in the 16-year conflict.
But he had also vowed to win more wars.
"America's interests are clear - we must stop the re-emergence of safe havens that enable terrorists to threaten America, and we must prevent nuclear weapons and materials from coming into the hands of terrorists," he said.