Nato has formally ended its 13-year combat mission in Afghanistan - heralding the start of a new phase of support for local Afghan troops.
Commanders lowered the flag during a ceremony in Kabul - raising the flag of the new mission named Resolute Support.
"We have lifted the Afghan people out of the darkness of despair and given them hope for the future," mission commander Gen John Campbell said.
Nato's Afghan deployment began after the 9/11 attacks against the US.
From 1 January the alliance's role will shift to a mainly training and support mission for the Afghan army.
Sunday's ceremony was low-key - held inside a gymnasium at the alliance headquarters away from the public.
A military band played as the flag of the International Security and Assistance Force (Isaf) was lowered in the presence of senior military personnel from both sides.
Unfurling the new flag, Gen Campbell said the mission "will serve as the bedrock of an enduring partnership" between Nato and Afghanistan.
"We honour coalition and Afghan fallen in this mighty struggle, those who paid the price for Afghanistan's freedom," he said, adding: "The road before us remains challenging but we will triumph."
At its peak, the US-led Isaf deployment involved more than 130,000 personnel from 50 countries.
But from 1 January, it will bring together around 12,000 men and women from Nato allies and 14 partner nations.
"The security of Afghanistan will be fully in the hands of the country's 350,000 Afghan soldiers and police. But Nato allies, together with many partner nations, will remain to train, advise and assist them," said Nato Secretary General Jens Stoltenberg in a statement.
More than a decade after this long and expensive mission began, the Taliban are still active and gaining in strength, launching a number of attacks in recent months, says the BBC's Sanjoy Majumder in Kabul.
This year has been the bloodiest in Afghanistan since 2001, with at least 4,600 members of the Afghan security forces dying in the fight against the Taliban.
It underscores the challenges that lie ahead of the Afghan security forces, our correspondent says.
Nearly 3,500 foreign troops have been killed since the beginning of the Nato mission.