US President Barack Obama has made an unannounced visit to Afghanistan to sign a post-2014 partnership deal that is designed to secure a "future of peace".
Mr Obama made his symbolic visit a year to the day after the killing of Osama bin Laden in Pakistan.
He signed a post-war partnership deal with President Hamid Karzai and told US troops their sacrifice had made a "light on the horizon" ahead.
"Neither Americans nor the Afghan people asked for this war, yet for a decade we've stood together," he said.
Mr Obama signed the ten-page pact pledging US aid to Afghanistan after 2014 when NATO combat troops leave.
"I'm here to affirm the bond between our two countries and to thank Americans and Afghans who have sacrificed so much over these last ten years," he said at Mr Karzai's presidential palace.
"We look forward to a future of peace. Today we're agreeing to be long-term partners."
The pact foresees the possibility of US forces staying behind to train Afghan forces and pursue the remnants of al-Qaeda, but does not commit the US to specific troop or funding levels for Afghanistan.
The deal, reached after months of painstaking negotiations, also states that the US does not seek permanent military bases in Afghanistan and was concluded just over two weeks before a NATO summit in Chicago.
Later, Mr Obama 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," he 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."