President Barack Obama and President Hamid Karzai of Afghanistan agreed after talks at the White House on Friday to slightly speed up the process that calls for American and other NATO forces to leave that war-torn country by late 2014. But Obama hedged on the much-discussed possibility of a U.S. military presence after that benchmark date.

The training of Afghan forces and the battleground successes against Islamist insurgents have gone well enough to meet NATO-set withdrawal goals and “accelerate them somewhat,” Obama said at a joint press conference with Karzai.

“Make no mistake: Our path is clear and we are moving forward,” Obama said. “Next year, this long war will come to a responsible end.”

The American president, who campaigned on his plan to end America’s involvement in what is now the country’s longest war, said he would collect advice from the Pentagon and military commanders on the ground “in the coming weeks” on how quickly U.S. forces can come home without risking hard-earned security gains. He would then announce the next phase of the pullout “in the coming months.”

Obama hedged on one of the most serious points of contention between the uneasy allies: The prospects of leaving a residual force beyond 2014 that would train Afghan troops and conduct counterterrorism operations. He declined to discuss the possible size of such a deployment and pointedly left open the possibility that America might leave entirely if the Afghan government does not agree to give U.S. troops immunity from prosecution.

“From my perspective at least, it will not be possible for us to have any kind of U.S. troops presence post-2014” without such an arrangement, Obama said.

Karzai, who had previously been wary of supporting immunity, said the talks at the White House had removed lingering obstacles regarding the custody of detainees and the nature of NATO-led operations.

“I can go to the Afghan people and argue for immunity for U.S. troops in Afghanistan in a way that Afghan sovereignty will not be compromised, in a way that Afghan law will not be compromised,” he said. As to how many forces should stay, Karzai added, “That’s not for us [Afghans] to decide."

Story continues

There are about 66,000 U.S. troops in Afghanistan. Afghan forces lead about 80 percent of security operations.

Was the war, which is now deeply unpopular with the U.S. public, worth fighting?

“It was absolutely the right thing,” said Obama, to invade Afghanistan after the Sept. 11, 2001, terrorist strikes to hunt down Osama bin Laden and al-Qaida and to ensure Afghanistan could not be used as a base to strike America again.

“We achieved our central goal—or have come very close to achieving our central goal—which is to decapitate al-Qaida, to dismantle it, to make sure that they can’t attack us again,” he said.

“At the end of this conflict, we are going to be able to say that the sacrifices that were made by those men and women in uniform has brought about the goal that we sought," the president added.

Obama had been asked whether the war was worth the hundreds of billions of dollars and thousands of U.S., NATO and Afghan deaths since the October 2001 invasion, especially given the now-abandoned dreams of fostering a vibrant democracy.

“Have we achieved everything that some might have imagined us achieving in the best of scenarios? Probably not. This is a human enterprise and, you know, you fall short of the ideal,” Obama acknowledged. “Did we achieve our central goal, and have we been able, I think, to shape a strong relationship with a responsible Afghan government that is willing to cooperate with us to make sure that it is not a launching pad for future attacks against the United States?

“We have achieved that goal; we are in the process of achieving that goal,” he said.

Obama also gave his strongest show of support yet for Afghan-led reconciliation talks including the Taliban Islamist militia, giving his approval to the establishment of a Taliban office in Doha, Qatar, for the purposes of the negotiations.

When Obama campaigned for re-election on a promise to end the war, he vowed that "the war in Afghanistan is ending" at one of his final rallies.

"We are leaving. We are leaving in 2014, period,” Vice President Joe Biden said in his debate with Republican rival Paul Ryan.

Except … maybe not. The Obama administration has been negotiating with Karzai on a possible residual fighting force—a notion that’s always been part of the White House’s strategy, just not necessarily one that it has highlighted. When Obama traveled to Afghanistan in May 2012, a senior administration official told reporters that any fighting force left there after 2014 would focus on “very specific, narrow missions” like counterterrorism and training Afghan troops.

Before Friday’s talks, both sides seemed to be in a negotiating posture. Senior Obama national security aide Ben Rhodes got headlines this week by saying that Americans might leave entirely (White House press secretary Jay Carney said roughly the same thing in late November).

Karzai took a tough line on the issue in an early December interview with NBC News, saying he had written to Obama to say NATO-led forces would have to leave entirely unless the U.S. turns over hundreds of detainees held at Bagram Air Base in Afghanistan and a nearby facility.

Obama aides have long trumpeted the pullout from Iraq as a major foreign policy victory. But that came about in part because of the collapse of negotiations over maintaining an American presence there. The Iraqi government refused to give U.S. forces immunity from prosecution—a deal breaker for Washington. Just weeks ago, Karzai was noncommittal.

"We can consider that question. I can go to the Afghan people and argue for it," Karzai told NBC. "But before I do that, the United States of America must make absolutely sure that they respect Afghanistan's sovereignty, that they respect Afghanistan's laws, that no Afghan is hurt or his or her rights violated by U.S. soldiers."