A ceremony has taken place in Kabul to mark the formal end of Nato's 13-year combat mission in Afghanistan.
Commanders lowered the alliance's flag during the ceremony and officially closed their combat headquarters in the country's capital.
Nato's deployment began in 2001 following the 9/11 attacks against the US.
The alliance's role will shift to a mainly training and support mission for the Afghan army from 1 January.
Speaking during the ceremony, US General John Campbell, commander of Nato's international security assistance force (Isaf), paid tribute to his troops.
"This country is safer and more prosperous than ever," he said, according to the Reuters news agency. "The insurgents have been beaten back and the Afghan National Security Forces are carrying the fight to the enemy."
BBC world affairs correspondent, Mike Wooldridge, said Gen Campbell also described what he saw as a bright future for Afghanistan, which until the 2001 invasion had been led by the fundamentalist Taliban regime.
At its peak, the US-led Isaf deployment involved more than 130,000 personnel from 50 countries.
But from 1 January, Nato chiefs say they intend to maintain a reduced force of around 13,000 soldiers.
The remaining forces will help train the Afghan national army, which is currently spearheading the fight against Taliban insurgents.
Despite the official end to Isaf's combat role, violence persists across much of the country.
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.
Meanwhile a suicide car bomber struck a police headquarters in Kandahar province on Monday, killing an officer and four civilians.
The flag-lowering ceremony was the first of two that will draw a formal close to Isaf's role by the end of December.
Nearly 3,500 foreign troops have been killed since the beginning of the mission.