British forces have handed over formal control of their last base in Afghanistan to Afghan troops, ending combat operations in the country after 13 years which cost hundreds of lives.
The handover was hailed by British Prime Minister David Cameron, but the southern Helmand province that foreign troops are leaving behind still confronts a resilient Taliban insurgency and remains a hub for opium production.
The Union Jack was lowered at Camp Bastion while the Stars and Stripes came down at the adjacent Camp Leatherneck - the last US Marine base in the country.
All NATO combat troops will depart Afghanistan by December, leaving Afghan troops and police to battle Taliban insurgents on their own.
The huge joint base built in the desert near the provincial capital Lashkar Gah was the most important installation for the NATO mission in Afghanistan.
Between 2010 to 2011, it housed almost 40,000 foreigners including sub-contractors.
Hundreds of US Marines and British troops are set to leave Helmand soon, though the precise date has not been revealed for security reasons.
In a ceremony on Sunday the Afghans took formal control of the base, despite already being present in a portion of it.
The British and US flags were lowered, leaving only Afghanistan's national flag to flutter in the breeze.
Britain's Prime Minister David Cameron later tweeted: "As flag lowers at Camp Bastion, our Armed Forces can return with their heads held high - proud of all they have achieved to keep us safe."
A total of 453 British troops and 2349 Americans were killed.
Many facilities such as pipelines, buildings, roads and even office furniture remain in place, with the US alone estimating $US230 million ($A248.85 million) worth of equipment is being left behind.
Marine General Daniel D. Yoo, regional commander, said the Afghan army is now capable of taking over the reins.
"I'm cautiously optimistic they will be able to sustain themselves. I know from my experience that they have the capability and the capacity if they allocate the resources properly," he said.
General Sayed Malook, who leads the Afghan forces in the region and has now established his quarters in the base, said the camp would become a military training centre and house 1800 soldiers.
"I'm certain we can maintain the security," he said.
Not everyone shares his optimism.
Atiqullah Amarkhail, a former high-ranking general turned analyst said the British mission in particular was a failure.
"You see that the British are leaving a broken Helmand, where the Taliban insurgency is at its highest, and government forces are struggling to hold territories, and the province is producing almost fifty per cent of the world's opium," he said.
"These are all signs that the British mission in Helmand have been a failure.
"They failed to prevent the Taliban come back and they are leaving it to Afghans and Americans to clean up. I see a bleak future for Helmand and southern Afghanistan now. The only hope is that the Afghan forces will be able to correct the British mistakes there."
After Camp Leatherneck and Bastion, the most important NATO bases will be at Kandahar, Bagram, Herat and Mazar-e-Sharif.
There are now about 40,000 foreign troops in Afghanistan, down from their 2011 peak of around 140,000.
A residual force of around 12,000 soldiers including 9,800 Americans and 500 Britons will remain after December as part of a security pact signed by new president Ashraf Ghani.
Their role will be training Afghan troops and counter-terrorism.