President Obama was upbeat last Christmas, standing before American troops in Hawaii as he proclaimed the end of the United States' combat mission in Afghanistan.

"Because of the extraordinary service of the men and women in the armed forces, Afghanistan has a chance to rebuild its own country," Obama said. "We are safer. It's not going to be a source of terrorist attacks again."

The president's grim tone and body language last week stood in sharp contrast as he explained why he has given up on leaving Afghanistan, one of the wars he inherited in 2009.

"The bottom line is, in key areas of the country, the security situation is still very fragile, and in some places there is risk of deterioration," Obama said in a televised address.

Obama's decision to keep roughly 9,800 troops in Afghanistan next year — rather than drawing down to 1,000 troops by the end of 2016, as the White House had once intended — comes amid Taliban advances and other alarming changes in the region. While Obama's shift is disturbing and may not put Afghanistan on a path toward stability, he has no good options.

The administration's decision is almost certainly driven by the advances of radical militant Islamist groups in Iraq, Syria, Yemen and Libya, where they have taken advantage of weak governments to seize ever-expanding territory. American officials say the Islamic State, the largest and most brutal among them, has a growing presence in Afghanistan, which could allow it to tap into the country's profitable opium trade.

Keeping a military contingent in Afghanistan in the short term, the officials say, may make the country less hospitable to the Islamic State and fighters who are attracted to its barbaric ideology. It might help the Afghan Army maintain control of the cities at a time when the Taliban is making alarming inroads across the country. It could dissuade more Afghans from joining the refugee exodus.

These are optimistic prospects; the most likely scenario might only be to maintain the security status quo for another year. It would be foolish to expect the drawdown delay to turn the war around, nor should this decision become an open-ended commitment that costs American taxpayers billions of dollars and takes American lives each year. The Obama administration and the Pentagon have been disingenuous, and at times downright dishonest, in their public assessment of the progress American forces and civilians have made in Afghanistan in recent years.

The key to ending the Afghan war remains a negotiated truce between the government and the leading factions of the Taliban, which has entered into talks with the Kabul government in recent years, but has not been persuaded to join the political process. It would also require that Afghan leaders take far clearer and bolder steps to root out the country's entrenched corruption and turn a hollow, dysfunctional government into a state Afghans start to believe in.

Whether those goals are attainable will ultimately depend on the competency and tenacity of Afghanistan's leaders. President Ashraf Ghani, who has been in office for a little over a year, has been a marked improvement over his erratic predecessor, Hamid Karzai.

"In the Afghan government, we have a serious partner who wants our help," Obama said last week.

The administration must redouble efforts during its remaining time in office to ensure that help is rendered as a part of a coherent, realistic strategy that ultimately cannot depend on American troops scrambling to hold the country together.

FROM AN EDITORIAL IN THE NEW YORK TIMES