The US commander of international forces in Afghanistan on Sunday hailed the achievements of 13 years of fighting against the Taliban, as NATO formally ended its war at a ceremony in Kabul.
"Together... we have lifted the Afghan people out of the darkness of despair and given them hope for the future," General John Campbell told assembled NATO soldiers.
"You've made Afghanistan stronger and our countries safer."
On January 1, the US-led International Security Assistance Force (ISAF) combat mission, which has suffered 3,485 military deaths since 2001, will be replaced by a NATO "training and support" mission.
The ceremony was arranged in secret due to the threat of Taliban strikes in the Afghan capital, which has been hit by repeated suicide bombings and gun attacks over recent years.
"I hope you take great pride in the positive impact you've made and will continue to make upon the Afghan people," Campbell said in a speech released by ISAF on Twitter as live broadcasts were banned for security reasons.
"The road before us remains challenging, but we will triumph."
Sunday's ceremony completed the gradual handover of responsiblity to the 350,000-strong Afghan forces, who have been in charge of nationwide security since the middle of last year.
But recent bloodshed has undermined claims that the insurgency is weakening and has highlighted fears that Afghanistan faces spiralling violence.