BAGRAM AIR BASE, Afghanistan — President Barack Obama said Wednesday a "time of war" was ending in a moment of American renewal, on a secret trip to Afghanistan a year after ordering the death of Osama bin Laden.
In a highly political election-year address from outside Kabul, Obama showcased his record as a commander-in-chief who ended two long wars, and conjured up a new dawn for a nation exhausted by conflict and recession.
"This time of war began in Afghanistan, and this is where it will end," Obama said, recalling a "decade under the dark cloud of war," after US troops were drawn into the Afghan quagmire after the September 11 attacks in 2001.
"Yet here, in the pre-dawn darkness of Afghanistan, we can see the light of a new day on the horizon," said Obama, seeking to use political capital earned by bringing troops home to validate his request for a second White House term.
Obama earlier dropped from night skies into Kabul amid secrecy and tight security and signed a deal with President Hamid Karzai, cementing 10 years of US aid for Afghanistan after NATO combat troops leave in 2014.
"Neither Americans nor the Afghan people asked for this war, yet for a decade we've stood together," Obama said at the signing ceremony.
"We look forward to a future of peace. We're agreeing to be long-term partners," said Obama who was due to make a high-security departure from Kabul later on Wednesday.
The pact, agreed last month, sees the possibility of American forces staying behind to train Afghan forces and pursue the remnants of Al-Qaeda for 10 years, but does not commit Washington to specific troop or funding levels for Afghanistan.
It is meant to send a signal to US foes that despite ending the longest war in US history, Washington intends to ensure Afghanistan does not revert to a haven for terror groups like Al-Qaeda.
But after a war that has cost the lives of nearly 3,000 US and allied troops, maimed tens of thousands more, saw thousands of Afghans killed and cost hundreds of billions of dollars, the future is deeply uncertain.
After nearly a week of hardball politics, Obama has been accused by angry Republicans of exploiting the heroism of Navy SEAL special forces who conducted the raid to kill bin Laden deep in Pakistan exactly a year ago.
But he clearly sought to use the trip to Afghanistan to bolster his credentials as a ruthless leader who had kept his promise to voters to turn from painful wars abroad to rebuilding at home ahead of November's election.
"The Iraq War is over. The number of our troops in harm's way has been cut in half, and more will be coming home soon. We have a clear path to fulfill our mission in Afghanistan, while delivering justice to Al-Qaeda," he said.
"As we emerge from a decade of conflict abroad and economic crisis at home, it is time to renew America," Obama said against a backdrop of military vehicles in their sandy desert liveries.
"A united America of grit and resilience, where sunlight glistens off soaring new towers in downtown Manhattan, and we build our future as one people, as one nation," Obama said.
Yet though he sought to put a capstone on the war, Obama's statement effectively meant that US troops could be fighting for two more years, and some could remain in danger for a decade more.
And Obama bluntly told American troops there was more suffering to come.
Obama also addressed soldiers at Bagram air force base.
"It's still tough, the battle is not yet over. Some of your buddies are going to get injured, some of your buddies may get killed," Obama said.
"There is going to be heartbreak and pain and difficulty ahead, but there is a light on the horizon because of the sacrifices you have made."
A senior US official said the post-war partnership deal signed after months of wrangling would make "clear to the Taliban, Al-Qaeda and other international terrorist groups that they cannot wait us out."
The deal states that the United States does not seek permanent military bases in Afghanistan and was concluded just over two weeks before a NATO summit in Chicago.
The trip underlined the symbolic power of the presidency at a time when Obama is locked in a fierce row with his Republican election foe Mitt Romney over claims he is hyping the bin Laden death anniversary for political gain.
On Monday, Obama had publicly questioned whether Romney would have taken the same decision as he did to launch an elite Navy SEALs raid deep into Pakistan to kill bin Laden in his lair in Abbottabad.
Romney accused Obama of inappropriately exploiting a moment of great national unity for political gain.
"Of course, I would have taken out Osama bin Laden, but what's the right course for the economy?" Romney said on CBS "This Morning."
"These are important issues people care about. The president's not talking about them. My campaign is."