Officials of Afghanistan and the United States on Tuesday signed a major security agreement to allow American troops to stay in the country after the end of the year.
The agreement signed in Kabul by National security adviser Hanif Atmar and US ambassador James Cunningham fulfils a campaign promise by new Afghan President Ashraf Ghani.
The bilateral security agreement was signed in a televised ceremony at the presidential palace just a day after Ghani was sworn in.
"As an independent country ... we signed this agreement for stability, goodwill, and prosperity of the people, stability of the region and the world," Ghani said in a speech after the signing.
Ghani's predecessor Hamid Karzai had long refused to agree to the deal, souring his ties with the United States. Karzai cited his anger over civilian deaths in US drone strikes and his belief that the war was not fought in the interests of his country.
Cunningham said the pact showed the United States remained committed to Afghanistan, where foreign forces have helped provide security since the 2001 toppling of the radical Islamist Taliban government through US intervention.
"It is a choice by the United States to continue cooperating with our Afghan partners on two important security missions: training and equipping Afghan forces and supporting cooperation against terrorism," Cunningham said.
Minutes after the security pact was signed, a similar agreement with NATO was ratified to allow the alliance's European members to contribute to a residual foreign force.
Ghani said in his speech that the agreement did not compromise Afghanistan's sovereignty and that either side has the right to withdraw from the pact within two years.
"The right to use force will be based on decisions by the Afghan government," Ghani said. "Our air space will be under our own control. International forces will not be able to enter mosques or other holy sites."
Under the agreement, 12,000 foreign military personnel are expected to stay after 2014, when the combat mission of Afghanistan's US-led NATO force ends.
The remaining force is expected to be made up of 9,800 US troops, with the rest from other NATO members. They will train and assist Afghan security forces in the war against the Taliban and its radical Islamist allies.
The US has the right to keep bases in Afghanistan as long as the security pact is in force, and in return it promises to raise funds to train and equip the Afghan security forces, which now number 350,000.
Ghani was inaugurated on Monday and called on the Taliban to join peace talks. He formed a unity government with election rival Abdullah Abdullah after a prolonged standoff over vote results that ended in a deal to make Ghani president and Abdullah a chief executive in the government with broad powers.