National security adviser Hanif Atmar and US ambassador James Cunningham signed the bilateral security agreement (BSA) in a televised ceremony at the presidential palace on Tuesday, a day after Ghani was inaugrated.
Hamid Karzai, who stepped down as president on Monday, had refused to sign the deal in a disagreement that came to symbolise the breakdown of Afghan-US relations.
"The signing sends the message that President Ghani fulfils his commitments. He promised it would be signed the day after inauguration, and it will be," Daoud Sultanzoy, a senior aide of Ghani's, told the AFP news agency.
"It shows the president's commitment to the Afghan security forces and confidence in our future relationship with the US. We are replacing uncertainty with certainty."
"The agreement will enable Afghanistan, the United States and the international community to maintain the partnership we've established to ensure Afghanistan maintains and extends the gains of the past decade," Jen Psaki, spokesperson for the US State Department, told journalists on Monday.
Parallel NATO agreement
Under the terms of the agreement, troops from Germany, Italy and other NATO members will join a force of 9,800 US soldiers, bringing numbers up to about 12,500.
After NATO's combat mission ends in December, the new mission, named Resolute Support, will focus on training and support for the Afghan army and police as they take on Taliban fighters. Negotiations over the pact had seen Karzai add new demands, shif positions and infuriated the US, Afghanistan's biggest donor.
He eventually refused to sign the agreement despite a "loya jirga" grand assembly that he convened voting for him to do so. On the campaign trail, both Ghani and his poll rival Abdullah Abdullah had vowed to reverse Karzai's decision. Washington had threatened to pull all US forces out by the end of the year, but it choose to wait through a long election deadlock until Afghanistan finally inaugurated a new president on Monday.
There are currently about 41,000 NATO troops in Afghanistan, down from a peak of 130,000 in 2012.