You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
National security adviser Hanif Atmar and U.S. Ambassador James Cunningham signed the bilateral security agreement in a televised ceremony at the presidential palace, one day after Ghani was inaugurated.
"As an independent country ... we signed this agreement for stability, goodwill, and prosperity of the our 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 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 over its sheltering of planners of the September 11 attacks.
"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 U.S.-led NATO force ends.
The force is expected to be made up of 9,800 U.S. 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 U.S. 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.
The Taliban, fighting to oust foreign forces and the U.S-backed government, have taken advantage of the paralysis in Kabul to launch attacks in an attempt regain strategic territory in provinces such as Helmand in the south and Kunduz in the north.
The Taliban have denounced the pact with the United States and repeated that on Tuesday, calling it a "sinister" plot by the United States to control Afghanistan and restore its international credibility as a military super power.
"Under the name of the security agreement, today Americans want to prepare themselves for another non-obvious and very dangerous fight," the Taliban said in a statement emailed to the media.
"With their bulk of artifices and deceptions they want to hoodwink the people. They think that the Afghan people do not know about their conspiracies and their sinister goals."