But with both candidates on the ballot in next month's Afghan presidential election runoff vowing to quickly sign the security agreement, Obama appeared more confident Sunday that there would be a continued U.S. troop presence after 2014.
After an overnight flight from Washington, Obama attended a briefing with U.S. officials. He said that as he entered the briefing room, he saw a poster of the Twin Towers destroyed in the 2001 terrorist attacks.
"It's a reminder of why we're here," he said.
Obama was accompanied by a few advisers, including senior counselor John Podesta, whose son is serving in Afghanistan. Country singer Brad Paisley joined Obama on Air Force One and entertained the troops as they waited for the president.
As is typical of recent presidential trips to war zones, the White House did not announce Obama's visit in advance. Media traveling with Obama for the 13-hour flight had to agree to keep the trip secret until the president had arrived.
After his remarks, Obama visited with injured service members being treated at a base hospital.
The president's visit took place against the backdrop of growing outrage in the United States over the treatment of America's war veterans. More than two dozen veterans' hospitals across America are under investigation over allegations of treatment delays and deaths, putting greater scrutiny on the Veterans Affairs Department. The agency already was struggling to keep up with the influx of forces returning home from Afghanistan and Iraq.
"We're going to stay strong by taking care of our wounded warriors and our veterans," Obama said to applause. "Because helping our wounded warriors and veterans heal isn't just a promise. It's a sacred obligation."
Obama has staked much of his foreign policy philosophy on ending the two wars he inherited from his predecessor, George W. Bush.
The final American troops withdrew from Iraq in the closing days of 2011 after the U.S. and Iraq failed to reach a security agreement to keep a small American residual force in the country. In the years that have followed the American withdrawal, Iraq has been battered by resurgent waves of violence.
U.S. officials say they're trying to avoid a similar scenario in Afghanistan. While combat forces are due to depart at the end of this year, Obama administration officials have pressed to keep some troops in Afghanistan after 2014 to continue training the Afghan security forces and undertake counterterrorism missions.
Pentagon officials have pushed for as many as 10,000 troops; others in the administration favor as few as 5,000 troops. Obama has insisted he will not keep any Americans in Afghanistan without a signed security agreement that would grant those forces immunity from Afghan law.
Follow Julie Pace at http://twitter.com/jpaceDC