WASHINGTON — President Obama said Wednesday that he planned to leave 8,400 American troops in Afghanistan until the end of his term, further slowing the drawdown in a 14-year war that Mr. Obama pledged to end on his watch but now seems likely to grind on indefinitely.

Acknowledging that the Taliban had retaken territory and were terrorizing the population, Mr. Obama said he was again adjusting his plan to withdraw American forces. The announcement will leave his successor with a substantial military commitment in the country, though far less than the nearly 40,000 troops deployed there when he took office.

“The security situation in Afghanistan remains precarious,” Mr. Obama said from the Roosevelt Room of the White House. “Even as they improve, Afghan security forces are still not as strong as they need to be.” Those troops, he said, had not been able to quell a string of attacks and suicide bombings, including in the capital, Kabul.

The United States has close to 10,000 soldiers in Afghanistan, where they train and equip Afghan forces, and carry out counterterrorism operations. When he last tinkered with the drawdown schedule, Mr. Obama said he hoped to reduce that number to 5,500 by early 2017.