US President Barack Obama has signed a strategic agreement with Afghan leader Hamid Karzai on a previously unannounced visit to Afghanistan.
The 10-year accord outlines military and civil ties between the countries after the end of Nato's mission in Afghanistan in 2014.
Mr Obama is also due to give a TV address to Americans back home.
The visit coincides with the first anniversary of Osama Bin Laden's killing in Pakistan.
It was a year ago that US special forces carried out a raid on Bin Laden's compound in Abbottabad and killed the leader of the al-Qaeda network.
After Mr Obama's arrival, Mr Karzai said a post-war agreement would seal an "equal partnership" between Afghanistan and the United States, reports say.
Mr Obama added the cost of war had been great for both nations, adding he looked forward to "a future of peace".
He acknowledged there would be difficult days ahead for Afghanistan, but said the Afghan people were taking control of their own future.
Later, Mr Obama thanked US troops in Afghanistan, saying Osama Bin Laden got justice a year ago.
He warned US troops of further hardship ahead in Afghanistan, but told them "there is a light on the horizon" after more than a decade of war.
The president called the agreement he signed with Mr Karzai "a responsible transition to Afghans taking control of their own country".
He said the change would not happen overnight because the US would not risk the gains so many had sacrificed to achieve.
"The reason America is safe is because of you," he added.
The US is to designate Afghanistan as a major non-Nato ally, US officials are quoted as saying by Reuters news agency.
Mr Obama will not make specific decisions on further reductions of US forces in Afghanistan until the autumn of 2012, the officials added.
Mr Obama is due to make his TV address from Bagram air base at 23:30 GMT.
The agreement is a first, symbolic step towards setting out a long-term relationship, says the BBC's Paul Adams in Washington.
It is designed to reassure the people of Afghanistan that they are not about to be abandoned when Nato ends its operations there in 18 months.
It is also meant to send a signal to the Taliban that it cannot simply expect to take over again when the Americans leave, our correspondent adds.
This is President Obama's third trip to Afghanistan since taking office.