US president Barack Obama has slipped into Afghanistan on the anniversary of the killing of 9/11 mastermind Osama bin Laden and signed an agreement cementing US commitment to the nation after American combat troops leave.
Alongside Afghan president Hamid Karzai, Mr Obama declared, "Together, we're now committed to replacing war with peace."
The partnership spells out the US relationship with Afghanistan beyond 2014, covering security, economics and governance. The deal is limited in scope and essentially gives both sides political cover. Afghanistan is guaranteed its sovereignty and promised it will not be abandoned, while the US gets to end its combat mission in the long and unpopular war but keep a foothold in the country.
The deal does not commit the United States to any specific troop presence or spending. But it does allow the US potentially to keep troops in Afghanistan after the war ends for two specific purposes - continued training of Afghan forces and targeted operations against al Qaida.
The terror group is present in neighbouring Pakistan but has only a nominal presence inside Afghanistan.
Mr Obama flew to the site of America's longest war not only as commander in chief but also as an incumbent president in the early stages of a tough re-election campaign.
His presence was a reminder that since taking office in 2009, Mr Obama has ended the war in Iraq and moved to create an orderly end for the US combat role in Afghanistan.
At a signing ceremony in Kabul with Mr Karzai, Mr Obama said the agreement paves the way for "a future of peace" while allowing the United States to "wind down this war".
Mr Karzai said his countrymen "will never forget" the help of US forces over the past decade. He said the partnership agreement shows the United States and Afghanistan will continue to fight terrorism together.
Mr Obama was greeted upon arrival at Bagram Air Field by Ryan Crocker, the US ambassador to Afghanistan. He then flew by helicopter to the presidential palace in Kabul.