Kabul, Afghanistan (CNN) -- The United States and Afghanistan signed a long-delayed security agreement Tuesday that will allow U.S. troops to stay in Afghanistan beyond the previous December deadline to withdraw. The deal was signed by Afghan National Security Adviser Mohammad Hanif Atmar and U.S. Ambassador to Afghanistan James Cunningham during a ceremony in Kabul. The future of the U.S. military's presence in Afghanistan beyond 2014 had been in doubt. Former Afghan President Hamid Karzai negotiated the security deal but then reneged, and it became clear that no agreement would be signed until after presidential elections this year. In February, the Obama administration announced for the first time that it had begun planning for the possible withdrawal of all U.S. troops by the end of 2014 if Afghanistan did not sign the agreement, which spells out the rights of U.S. troops operating there.
@highlight
NEW: President Barack Obama hails "historic day" that will aid long-term Afghan security
@highlight
Signing comes one day after the swearing-in of Afghanistan's new president
@highlight
United States was poised to withdraw all its troops by end of year if deal wasn't signed
@highlight
Agreement was negotiated by former Afghan President Hamid Karzai, who later reneged
He also paid tribute to the contributions of @placeholder, saying that while America's relationship with him has been "punctuated by disagreements," he is recognized by the world as "a nationalist, a patriot and an important figure who stepped forward when his country needed him."