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.

Judges said their work laid "an intellectual foundation" for policies in areas such as bankruptcy legislation and political constitutions.
The pair will receive 8 million Swedish krona (Â£744,652) from the committee.
Mr Hart, who was woken with the news at 4.40am, said his first reaction had been to hug his wife and wake his younger son.
Mr Holmstrom said he felt "very lucky" and "grateful".
The Royal Swedish Academy of Sciences said that Mr Hart and Mr Holmstrom's work was "valuable to the understanding of real-life contracts and institutions".
It also said it could identify "potential pitfalls in contract design."
Working separately, the two created tools to help determine whether public sector workers should receive fixed salaries or performance-based pay, and whether providers of public services should be publicly or privately owned.
Mr Holmstrom in particular is known for his research into how contracts and incentives affect corporate behaviour.
The former Nokia board member declined to say whether he thought executive pay was too high these days, but commented: "My personal view is that [top executives' contracts] are too complicated today."
Mr Holmstrom, aged 67, is a professor of economics and management at Massachusetts Institute of Technology, while Mr Hart, born in 1948, is an economics professor at Harvard University in the US.
The pair saw off competition from the World Bank's new chief economist Paul Romer, who was widely tipped to win.
New York University's Stern Business School, where Prof Romer teaches, sparked controversy last Thursday when it accidently published a press release naming him as the winner.
It quickly took down the release, saying it was only preparing for a possible win.
Others believed to be the running included Olivier Blanchard, a former chief economist at the International Monetary Fund, and Edward Lazear, a fellow at the Hoover Institution, Stanford University.
The economics prize is the only Nobel not created by Alfred Nobel, and was instead launched in 1968, long after the philanthropist's death.
To date Americans have dominated the award, with 55 of the 76 laureates holding US citizenship, including those with dual nationalities.
Last year Scottish-born economist Angus Deaton won the prize for his use of data to investigate income inequality and inform economic policy.
It is the fifth Nobel to be announced this year, after prizes for physiology or medicine, physics, chemistry and peace were awarded last week.
The Nobel prize for literature will be awarded on Thursday.
Nato has formally ended its 13-year combat mission in Afghanistan - heralding the start of a new phase of support for local Afghan troops.
[NEXT_CONCEPT]
UK-born Oliver Hart and Bengt Holmstrom of Finland have won the Nobel economics prize for work on contract theory.