"Together... we have lifted the Afghan people out of the darkness of despair and given them hope for the future," the US commander of ISAF, General John Campbell, told the NATO soldiers assembled for the ceremony.
"You've made Afghanistan stronger and our countries safer," he said in the speech, released by ISAF on Twitter. Live broadcasts were banned for security reasons.
"The road before us remains challenging, but we will triumph," he added.
The ceremony completed the step-by-step handover of responsibility to Afghan forces, who have nominally been in charge of security since the middle of last year. The ISAF combat mission will now transition to a "training and support" mission under NATO leadership, starting on January 1.
The Resolute Support mission will see 13,500 soldiers, mostly American, provide training and aid to Afghan army, paramilitary and police forces as they try to put down a deadly insurgency by the Taliban that has caused almost 10,000 casualties this year alone - the highest figure since the United Nations began keeping records in 2008.
However, US President Barack Obama recently expanded the remit of US forces remaining in the country, allowing them to undertake counterterrorism operations against both the Taliban and al Qaeda, as well as to give Afghan forces backing on the ground and from the air for at least the next two years.
ISAF, which comprised troops from about 50 nations, was set up to provide security after the US-led invasion of 2001 in which the Taliban regime was ousted following the September 11 attacks.
Altogether some 3,500 foreign troops were killed in 13 years of fighting, 2,224 of them American.
At its peak in 2010, the force counted 140,000 troops as Obama boosted numbers in a bid to drive insurgents out of strategically important regions such as the southern provinces of Helmand and Kandahar.
Many Afghans fear that the withdrawal of NATO combat troops will contribute to a deteriorating security situation, with Afghan officials complaining of a lack of assets such as air support, medical evacuation and intelligence.
Around 5,000 Afghan security personnel have been killed so far this year, some 3,200 of them policemen.
The country is still very politically unstable, and still lacks a cabinet three months after the inauguration of President Ashraf Ghani in September.