Obama announced the United States will keep 9,800 troops in Afghanistan through most of 2016 before drawing down to about 5,500 by the end of that year. The decision prolongs the American role in a war that has already lasted 14 years. The president made the announcement in the White House alongside Vice President Joe Biden, Defense Secretary Ash Carter and Chairman of the Joint Chiefs of Staff Joseph Dunford.

“While America’s combat mission in Afghanistan may be over, our commitment to Afghanistan and its people endures,” said Mr. Obama, “I will not allow Afghanistan to be used as safe haven for terrorists to attack our nation again.”

In 2014, the president announced the U.S. mission in Afghanistan would decrease from 9,800 troops to 1,000 by the end of 2016. So the announcement is a reversal for the president, who sees “ending two wars” as one of his greatest achievements. The president had planned to withdraw virtually all U.S. troops from the country by the end of 2016 except those needed to protect the U.S. embassy in Kabul.

The decision comes after months-long comprehensive reviews that began this past spring and included conversations among Obama, Afghan President Ghani, and Afghan Chief Executive Officer Abdullah. While the announcement coincides with the Taliban’s capture of Kunduz last month, the plan to keep thousands of troops in Afghanistan was being considered and reviewed for months. The Taliban now controls more of Afghanistan than at any point since the 2001 U.S. invasion.

The troops will be stationed in Jalalabad, Kandahar, Kabul and Bagram, Obama said, but he did not give a timeframe for when the force level will decrease from 9,800 to 5,500, saying it is a decision that will be made in consultation with commanders on the ground and allies.

The troops will be tasked with conducting two non-combat missions – a counter-terrorism mission to go after Al Qaeda and threats to the homeland and to train, advise and assist Afghan security forces. While the president has succeeded in vastly reducing the American military presence in both countries, the United States has returned a modest force to Iraq to help Baghdad in its fight against the Islamic State. And with Thursday’s announcement, Mr. Obama leaves a commitment of thousands of troops — and the decision about how and when to end the war in Afghanistan — to his successor.