NATO has formally ended its war in Afghanistan with a ceremony in Kabul, 13 years after its combat mission began.
The alliance leaves behind a new mission called Resolute Support, to help local Afghan forces.
The handover was arranged in secret because of the threat of Taliban strikes in the capital.
“Today NATO completes its combat mission, a 13-year endeavour filled with significant achievements and… tremendous sacrifice, especially by the thousands of coalition and Afghan army and police wounded…who gave so much to build a brighter future for this war-torn land,” General John Campbell, Commander of the International Security Assistance Force (ISAF), told the ceremony.
Over 12,000 foreign troops will remain to help the Afghans fight the insurgents.
Mohammad Anif Atmar, security adviser to Afghan President Ashraf Ghani, made it clear they will be needed.
“We stepped into a partnership together at the height of war, specifically we need your help to build the systems necessary to ensure the long-term sustainability and critical capabilities of our armed forces,” he said.
Recent bloodshed including in Kabul has undermined claims that the insurgency is weakening.
The Taliban said NATO and the US had failed and were fleeing Afghanistan.
This year has been the bloodiest in the country since 2001, with some 4,600 Afghan troops killed as they fought the Taliban.