During a news conference July 6, President Obama announced the United States will leave 8,400 troops in Afghanistan when he steps down next year. (Reuters)

President Obama announced revised troop plans for Afghanistan on Wednesday, keeping 8,400 U.S. troops in the country when he steps down early next year, the clearest indication yet of his inability to end the long war there.

“I strongly believe that it is in our national security interest, especially after all the blood and treasure we’ve invested in Afghanistan over the years, that we give our Afghan partners the very best opportunity to succeed,” Obama said in remarks at the White House. He had hoped to leave a force of 5,500 in early 2017.

The decision is likely to be the last in a series of adjustments that Obama, who came into office promising to end costly U.S. wars in the Muslim world, has made to a withdrawal schedule he hailed in 2014 as proof the United States was “finishing the job” in Afghanistan.

That goal has remained stubbornly out of reach as security has deteriorated across Afghanistan in recent years. Local forces, reliant on foreign troops for air power and other kinds of support, have struggled to contain sustained offensives by Taliban militants who, even after the death of their leader this spring, remain a potent force.

President Obama, flanked by Defense Secretary Ashton B. Carter, center, and Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff, delivers a statement Wednesday at the White House on the deployment of U.S. troops in Afghanistan. (Win McNamee/Getty Images)

Obama, speaking alongside Defense Secretary Ashton B. Carter and Gen. Joseph F. Dunford Jr., chairman of the Joint Chiefs of Staff, said the United States is no longer fighting a “major ground war” in Afghanistan. He ticked off a list of accomplishments he said made the country a safer, more inclusive place than it was under the Taliban’s repressive rule.

He also acknowledged that the Afghan government would need more time to build up its military capacity before it can stand fully on its own.

There are now about 9,800 U.S. troops in Afghanistan, tasked with a dual mission to support local troops and hunt down al-Qaeda and other militants. That compares with a force of about 100,000 stationed there during Obama’s 2010 troop surge.

In a conference call with reporters to discuss the announcement, senior administration officials said the revised troop number, a slight decrease from the current level, reflected recommendations from the U.S. commander in Afghanistan, Gen. John W. “Mick” Nicholson Jr. The changes were approved by Carter and Dunford, they said.

“The president’s guidance was just to have a recommendation as to what the best presence and necessary resources would be at the end of 2016,” said one official who, like others, spoke on a condition of anonymity imposed by the White House.

“This was . . . not about calibrating how many troops we could afford to reduce — it was about designing the best possible presence to carry out those missions through the end of the year,” the official said. “This was the Pentagon’s recommendation.”

In a statement, Afghan President Ashraf Ghani welcomed Obama’s announcement, which signaled an extension of crucial support at a time when militant attacks have exposed local forces’ weaknesses in key military areas, including intelligence and air power.

“The decision is a sign of continued partnership between our nations to fight our common enemy and strengthen regional stability,” Ghani said through his spokesman, Haroon Chakhansuri.

Taliban spokesman Zabiullah Mujahid said the United States had been unable to quash the group with a force of 100,000 and would fail to do so with a smaller footprint. “However long American invading forces remain in Afghanistan, their defeat will be definite,” he said in a statement.

Already over the past two years, Obama had given commanders in Afghanistan new powers to combat militants, an acknowledgment that the official end to U.S. combat operations at the end of 2014 did not signal a halt to the fighting.

Daniel F. Feldman, who was Obama’s special representative for Afghanistan and Pakistan until last year, said Wednesday’s announcement would send a positive signal to Afghanistan and its neighbors.

“It’s important for what it means for military and security resources, and important symbolically in terms of demonstrating continued commitment,” Feldman said. Pakistan, where Taliban leaders are believed to reside, continues to play an important role in Afghanistan’s fate.

But Wednesday’s decision could be a political liability for Obama, opening him to criticism for altering earlier plans, while failing to satisfy Republicans who believe Afghanistan’s insecurity merits a larger force.

Sen. John McCain (R-Ariz.), who chairs the Senate Armed Services Committee, said he would have preferred to keep current troop levels untouched.

“When the President himself describes the security situation in Afghanistan as ‘precarious,’ it is difficult to discern any strategic rationale for withdrawing 1,400 U.S. troops by the end of the year,” he said in a statement.

As part of current military plans, the United States will also maintain six major bases across Afghanistan. That will afford U.S. and NATO troops greater reach into contested areas and make it easier to rebuild a larger force if the next U.S. president decides to do so.

The announcement comes several days before Obama attends a NATO summit in Poland that had imposed something of a deadline on the White House.

Officials acknowledged that about 40 governments participating in the Afghanistan effort, including many from NATO, want to know how to calibrate their own contributions of about 6,000 troops. Germany and Italy make the largest contributions, with nearly 1,000 troops each.

The announcement “allows us to have a more constructive discussion at the NATO summit,” an official said.

Officials did not specify what additional funds would be needed to maintain troop levels beyond the initially budgeted 5,500 but said they would discuss the matter with Congress.

“It is time that the President level with the American people about what it will really take to achieve our goals in Afghanistan, and how much it will cost,” Rep. Mac Thornberry (R-Tex.), chair of the House Armed Services Committee, said in a statement.

Officials said they anticipated no change in the U.S. mission. Under the expanded military authorities Obama granted in May, U.S. troops are now allowed to be present at the Afghan corps level and at an “expeditionary level.” Commanders can also deploy U.S. air assets to support an ongoing Afghan operation and to intervene if Afghan forces find themselves in difficulty. Those moves were a reflection of the danger posed by the Taliban, even though the White House has said it is no longer at war with the group.

Obama’s announcement tees up additional decisions for the next U.S. president, who will also have to grapple with the wars in Iraq and Syria and the growth of the Islamic State.

As secretary of state, presumptive Democratic nominee Hillary Clinton sent hundreds of diplomats and aid workers to Afghanistan in Obama’s “civilian surge.” If elected, she is expected to take a more hawkish view of using U.S. military power overseas than Obama.

Donald Trump, the presumptive Republican nominee, has said he would probably leave U.S. troops in Afghanistan but has not provided specifics.

U.S. officials emphasized that successful peace negotiations remain the only way to bring the war to a sustainable end. They said the administration continues to support talks “without preconditions.”

While Ghani has sought to foster negotiations with the Taliban, militants have shunned those talks. Last year, Pakistani-hosted talks collapsed after one meeting, and invitations to the Taliban to return to the table have been rejected since then.

Obama said his decision to leave a larger force in Afghanistan signaled to Taliban militants their inability to prevail after almost 15 years of war. It is also a reminder of the same point to the United States.

“Even as we work for peace, we have to deal with the realities of the world as it is,” Obama said. “And we can’t forget what’s at stake in Afghanistan.”

Tim Craig in Kabul contributed to this report.