The United States and Nato have formally ended their war in Afghanistan with a ceremony at their military headquarters in Kabul.
The ceremony came as the insurgency they fought for 13 years remains as ferocious and deadly as at any time since the 2001 invasion that unseated the Taliban regime following the September 11 attacks.
The symbolic ceremony marked the end of the US-led International Security Assistance Force, which will transition to a supporting role with 13,500 soldiers, most of them American, starting on January 1.
General John Campbell, commander of Isaf, rolled up and sheathed the green and white Isaf flag and unfurled the flag of the new international mission, called Resolute Support.
"Resolute Support will serve as the bedrock of an enduring partnership" between Nato and Afghanistan, Mr Campbell told an audience of Afghan and international military officers and officials, as well as diplomats and journalists.
He paid tribute to the international and Afghan troops who have died fighting the insurgency, saying: "The road before us remains challenging but we will triumph."
From January 1, the new mission will provide training and support for Afghanistan's military, with the US accounting for almost 11,000 members of the residual force.
President Ashraf Ghani, who took office in September, signed bilateral security agreements with Washington and Nato allowing the enduring military presence. The move has led to a spike in violence as the Taliban have claimed it as an excuse to step up operations aimed at destabilising his government.
Isaf was set up after the US-led invasion as an umbrella for the coalition of around 50 nations that provided troops and took responsibility for security across the country.
It ends with 2,224 American soldiers killed, out of a total of some 3,500 foreign troop deaths.
The mission peaked at 140,000 troops in 2010 with a surge ordered by US president Barack Obama to root the insurgents out of strategically important regions, notably in the southern provinces of Helmand and Kandahar, where the Taliban had its capital from 1996 to 2001.
Mr Obama recently expanded the remit of the US forces remaining in the country, allowing them to extend their counter-terrorism operations to the Taliban, as well as al Qaida, and to provide ground and air support for the Afghan forces when necessary for at least the next two years.