President Obama says the U.S. will maintain 9,800 troops in Afghanistan through most of 2016 and will not go down to a normal embassy presence by the end of 2016. (AP)

President Obama said Thursday that he will keep 5,500 U.S. troops in Afghanistan into 2017, ending his ambitions to bring home most American forces from that war-torn country before he leaves office.

The president’s decision came after an extensive months-long review that included regular discussions with Afghanistan’s leaders, his national security team and U.S. commanders in the field. The move reflected a painful, if predictable, reality on the ground in Afghanistan, where the Taliban has seized new territory over the past year as Afghan troops have taken over the vast majority of the fighting.

“Afghan forces are still not as strong as they need to be,” Obama said Thursday morning from the White House, explaining his decision. “. . . Meanwhile, the Taliban has made gains, particularly in rural areas, and can still launch deadly attacks in cities, including Kabul.”

Obama said he will also dramatically slow the pace of the reduction of American forces and plans to maintain the current U.S. force of 9,800 through “most of 2016.” The post-2016 force will still be focused on training and advising the Afghan army, with a special emphasis on its elite counter­terrorism forces. The United States will also maintain a significant counterterrorism capability of drones and Special Operations forces to strike al-Qaeda and other militants who may be plotting attacks against the United States.

The revised troop plans came after Afghan forces were driven from Kunduz, the first major city to fall to the Taliban since the war began in 2001. Two weeks passed before the Afghans, with some support from U.S. planes and Special Operations advisers, took the city back from the Taliban. Militants are now threatening other cities. “The bottom line is, in key areas of the country the security situation is still very fragile, and in some places there’s risk of deterioration,” Obama said.

The president praised the Afghan government, under the leadership of President Ashraf Ghani, as a willing partner, and he lauded the Afghan troops, who have taken significant casualties. Both were critical factors in his decision to keep U.S. troops in the country.

“Every single day, Afghan forces are out there fighting and dying to protect their country,” Obama said. “They’re not looking for us to do it for them.”

The president insisted that his decision to abandon his plans to bring home U.S. troops was not a disappointment, even as he acknowledged the nation’s war weariness after more than 14 years of fighting in Afghanistan and Iraq. “I do not support the idea of endless war,” he said.

His decision to keep troops in Afghanistan follows the surprising collapse of much of the U.S.-trained Iraqi army last year under pressure from Islamic State militants. Republican critics have charged that Obama withdrew troops too quickly from Iraq, precipitating the collapse of the Iraqi army and the rise of the Islamic State.

The president did not mention the Iraqi failures in his statement from the White House. White House officials said that the Iraq setbacks did not influence Obama’s decision and that the two situations are not comparable, because the Afghan government was eager to maintain a long-term U.S. presence. Such conditions did not exist in Iraq.

Afghan officials on Thursday welcomed the move to keep 9,800 troops in the country. “It’s very positive in light of the continued problems that this region is facing,” said Mohammad Daud Sultanzoy, a presidential candidate in 2014 who is now allied with Ghani. “Our security [forces] have shown the will and capability to fight, but we still need the support of our allies, especially the United States.”

In Ghazni province, where Afghan forces are locked in a bloody fight with the Taliban, Gen. Sayed Malok called it a “good decision at the moment but a temporary solution.” He called for a more robust effort to train and equip Afghan forces.

The decision is a significant departure from the exit plan that Obama announced in a White House Rose Garden speech in May 2014. In keeping with his promise to “turn the page” on the costly wars launched by his predecessor, Obama said then that he would reduce the U.S. footprint to about 1,000 troops, all based in Kabul, by the end of 2016.

It is also a stark illustration of how persistent militant threats have stood in the way of Obama’s promises to end the ground wars that have dominated U.S. foreign policy since the Sept. 11, 2001, terrorist attacks.

In addition to a resurgent Taliban, al-Qaeda appears to have staked out new ground in Afghanistan, far from the group’s mountain enclaves to the northeast. Last week, U.S. forces began a major operation against al-Qaeda in Kandahar, launching 63 airstrikes on militant training bases.

David Sedney, a former Pentagon official who is a senior associate at the Center for Strategic and International Studies, said the 2015 fighting season was “the most massive, fiercest” yet.

“The Taliban are already signaling that next year’s offensive will be bigger and bloodier than this year’s. The Taliban are bad; Daesh is worse,” Sedney said, referring to the emerging Islamic State presence in Afghanistan.

Administration officials portrayed the decision as a natural extension of a strategy that was making progress, rather than an indication that the president’s original plan had failed. “I don’t think anyone ever intended that the job, so to speak, would be finished” despite Obama’s time­table, said Lisa Monaco, a senior White House official. “We always said that we would continue to have a presence there.”

Under the new plan, the U.S. military will retain bases in Kabul, as planned, but also have forces at Bagram air base and at bases outside Kandahar and Jalalabad, the largest cities in Afghanistan’s southern and eastern regions.

Obama emphasized that Afghans would continue to take the lead role in the fighting, with Americans providing advice and some counterterrorism support from bases outside Kabul. “These bases will give us the presence and the reach our forces require to achieve their mission,” he said.

The larger force of 5,500 troops is projected to cost about $15 billion a year, or about $5 billion more than the smaller, 1,000-person Kabul-based force would have cost.

Defense Secretary Ashton B. Carter, speaking at the Pentagon, said the next president will probably need to make decisions about the long-term position of U.S. forces­ in Afghanistan.

“Is it going to be 5,500 forever?” he told reporters. “I can only say this: That is our best estimate now of what we should plan for and are planning for and budgeting for for 2017.”

Although U.S. deaths have fallen off dramatically in recent years, the change may also mean more U.S. casualties. This year, 25 American service members and civilians have been killed in the country.

Obama emphasized that the relatively small American military presence, down from 100,000 at the war’s peak, would not decide the war’s outcome, and he emphasized that peace talks offered the sole viable solution to the long, bloody civil war.

“By now, it should be clear to the Taliban and all who oppose Afghanistan’s progress, the only real way to achieve the full drawdown of U.S. and foreign troops from Afghanistan is through a lasting political settlement with the Afghan government,” Obama said.

Sudarsan Raghavan, Sayed Salahuddin and Mohammad Sharif in Kabul contributed to this report.

Read more:

In Afghanistan, the art of fighting extremism

Afghans who once watched war from afar forced to flee as front lines shift

Afghan forces straining to keep the Taliban at bay