President Obama announced Wednesday that he will keep roughly 3,000 more U.S. troops in Afghanistan than previously announced – prolonging America’s role in a war that already has lasted more than a decade.

Obama said he will leave around 8,400 U.S. troops in Afghanistan when he leaves office in January.

"The Taliban remains a threat," Obama said from the Roosevelt Room with Defense Secretary Ash Carter and the Joint Chiefs of Staff chairman, Gen. Joseph Dunford.

Obama had planned to drop troop levels to 5,500 troops, from 9,800, by the end of 2016. But Taliban resurgence has forced a reconsideration of his administration's exit strategy.

Obama said he made the decision after receiving recommendations from top military leaders who urged him to revise his earlier plan. He said boosting the planned troops levels would help U.S. allies prepare their own contribution to the fight in Afghanistan and would help the next president make good decisions about the future of U.S. involvement in the country where America has been fighting since 2001.

"The decision I'm making today ensures that my successor has a solid foundation for progress in Afghanistan, as well as the flexibility to address the threat of terrorism as it evolves," Obama said.

He added, "l firmly believe the decision I'm announcing is the right thing to do."

Obama said the U.S. mission would remain narrowly focused on "training and advising" Afghan forces and supporting counterterrorism operations against the remnants of al-Qaida, the group that attacked the U.S. on Sept. 11.

"We are no longer engaged in a major ground war in Afghanistan," he said. Still, he said, Americans serving in their more limited missions there still face serious dangers.

Last month a group of more than a dozen former U.S. ambassadors and former commanders of U.S. forces in Afghanistan wrote to Obama urging that he sustain the current level of U.S. troops through the remainder of his term in office. They included Gen. John F. Campbell, who had been the top U.S. commander in Kabul until four months ago, and retired Gen. David Petraeus.

"Unless emergency conditions require consideration of a modest increase, we would strongly favor a freeze at the level of roughly 10,000 U.S. troops through January 30," they wrote in a June 1 letter. "This approach would allow your successor to assess for herself or himself and make further adjustments accordingly."

Obama's announcement will help shape his legacy. A president who came into office promising to end the wars he inherited, has instead found himself wrestling with continued conflicts in both Iraq and Afghanistan and new conflicts in Syria and Libya.

Obama's announcement comes a day before he heads to a NATO summit in Poland, where Afghanistan is high on the agenda.

Fox News' Lucas Tomlinson and The Associated Press contributed to this report.