WASHINGTON (AP) -- In President Barack Obama's twin narratives, the United States is both leaving Afghanistan and staying there.
The different messages are meant for different audiences, one at home and one away. As Obama's brief, symbolic visit to Afghanistan on Wednesday made clear, the more important audience is American voters fed up with a war that will be in its 12th year on Election Day in November.
The president flew in secret to sign a long-awaited security compact with Afghanistan. It was after midnight in Kabul when the signing took place, and 4 a.m. there when Obama addressed Americans in a specially arranged speech at 7:30 p.m. Washington time on network television. By the time most Afghans woke up, Obama was gone.
"My fellow Americans," Obama said from Bagram Air Field, "we have traveled through more than a decade under the dark cloud of war. Yet here, in the predawn darkness of Afghanistan, we can see the light of a new day on the horizon."
The backdrop of armored troop carriers matched Obama's message of praise for U.S. forces who fought and died in Afghanistan, but it was an odd fit for what followed -- a direct appeal to American optimism and self-interest in an election year.
"As we emerge from a decade of conflict abroad and economic crisis at home, it is time to renew America," Obama said.
The agreement pledges ongoing U.S. support for Afghanistan after 88,000 U.S. combat forces leave. The pact envisions wide-ranging U.S. involvement in Afghan economic and security affairs for a decade, if only as an adviser or underwriter. It gives Afghans a promise of more roads and schools and support for the uneven Afghan fighting forces.
It gives the U.S. a security foothold in the country to bolster Afghan forces for their continued fight against Taliban-led militants or al-Qaida, and to keep an eye on neighboring Iran. Obama's emphasis on a long-term U.S. commitment to Afghanistan reflects a lingering worry about the threat of a Taliban resurgence after 2014, when U.S. and NATO combat forces are scheduled to leave.
The Taliban claimed responsibility for attacks that rocked Kabul a few hours later. Officials and witnesses said a suicide car bomber and Taliban militants disguised in burqas attacked a compound housing hundreds of foreigners in the Afghan capital, killing seven.
With the agreement signed Wednesday in Afghanistan, the U.S. also has in mind the strategic significance of preserving a military partnership on Iran's eastern frontier, even if it does not include permanent U.S. bases.
Even after the U.S. combat mission is concluded in 2014, it is likely that thousands of U.S. troops will remain for some years to conduct counterterrorism strikes and otherwise train and advise Afghan forces, and help the Afghans collect and exploit intelligence on insurgents and other military targets.
The agreement was long sought by the U.S.-backed government of Afghan President Hamid Karzai, the perpetually skittish leader who has publicly voiced fears of what would befall his country if the United States quickly packed up and left.
"I recognize that many Americans are tired of war," Obama said in the speech. "But we must finish the job we started in Afghanistan and end this war responsibly."
The larger rationale of the agreement was to reassure Afghan leaders that the United States would not repeat the mistake it made following the Soviet withdrawal from Afghanistan in 1989. Then, Washington withdrew support for anti-Soviet militia forces in Afghanistan and set the stage for Taliban rule. The Taliban then allowed al-Qaida to use the country to plan the terror attacks of Sept. 11, 2001.
In his speech, Obama turned the signing of the promise to stay in Afghanistan into a vehicle for his other promise -- to go.
The signing was a quick and businesslike affair at Karzai's palace in Kabul. There were pleasantries, but no pageantry. There was also no opportunity for Karzai to make one of the off-message demands or denunciations of U.S. behavior that have exasperated U.S. officials in the past, even when they acknowledged Karzai had a point.
"The Afghan people will understand that the United States will stand by them," Obama said, with Karzai seated beside him at the signing table. "They will know that the United States can achieve our goals of destroying al-Qaida and denying it a safe haven, but at the same time we have the capacity to wind down this war and usher in a new era of peace here in Afghanistan."
With that, it was back to the sprawling U.S. air base outside the capital to underscore that last point, that he will close down the war and bring U.S. forces home.
By alighting in Afghanistan on the anniversary of the raid that killed Sept. 11 mastermind Osama bin Laden, Obama was also making an unsubtle show of the power of the presidency. Not only is he the commander in chief who can finally end what many Americans see as an unwinnable war -- Obama was telling Americans that he is the commander in chief who bagged the biggest bad guy in America's recent history.
"This time of war began in Afghanistan, and this is where it will end," Obama said in the speech.
Republicans warily saluted Obama's war-zone trip but accused him of craven politics nonetheless.
"Clearly this trip is campaign-related," said Sen. Jim Inhofe, a senior member of the Senate Armed Services Committee. "This trip to Afghanistan is an attempt to shore up his national security credentials, because he has spent the past three years gutting our military," a reference to tightening defense budgets.
Obama's presumed Republican opponent, Mitt Romney, was in New York accusing the president of politicizing the fleeting unity that came with bin Laden's death.
Stephen Biddle, a defense analyst at the Council on Foreign Relations, said Obama will be hard pressed to convince Afghans or Pakistanis that the United States will remain an effective security partner once most U.S. troops have gone home.
"The trouble is, he is talking to audiences that have a very strong belief that the United States is going to abandon them," Biddle said in a phone interview.
Anne Gearan and Robert Burns cover national security issues for The Associated Press.