Afghanistan and the United States signed a security pact on Tuesday to allow U.S. forces to remain in the country past the end of year, ending a year of uncertainty over the fate of foreign troops supporting Afghanis as they take over responsibility for the country's security.

Afghan, American and NATO leaders welcomed the deal, which will allow about 10,000 American troops to stay in the country after the international combat mission ends Dec. 31. Former Afghan President Hamid Karzai had refused to sign it despite U.S. threats of a full withdrawal in the absence of legal protections for American forces. U.S. officials have said that the delay in the deal's signing does not affect plans for next year.

President Ashraf Ghani Ahmadzai, who was sworn into office a day earlier, told the assembled crowd that the agreement signaled a fundamental shift for the positive in the country's relations with the world.

"This agreement is only for Afghan security and stability," he said. "These agreements are in our national interest. The Bilateral Security Agreement will pave the ground for Afghanistan to take control, "he added.

Newly appointed Afghan national security adviser Mohmmad Hanif Atmar and U.S. Ambassador James Cunningham signed the agreement at the presidential palace in the capital, Kabul. A second agreement allowing NATO troops to stay in the country was also signed during the same ceremony.

Government Chief Executive Abdullah Abdullah, who has assumed a post aking to prime minister after signing a power-sharing agreement with Ghani Ahmadzai, also welcomed the security deal.

"It has been signed after very careful considerations," he said, adding that "the BSA is not a threat to our neighbors. It will help strengthen peace and stability in the region."

NATO Secretary General Anders Fogh Rasmussen welcomed the agreement, saying it outlined the group's new mission to train, advise and assist Afghan forces.

"We remain committed to help finance the Afghan security forces through 2017, to help Afghanistan to further strengthen its institutions, and to further develop our political and practical cooperation with Afghanistan through our Enduring Partnership," he said in a statement.