CAMP LEATHERNECK, Afghanistan - British forces Sunday 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 Union Jack was lowered at Camp Bastion in the southern province of Helmand, 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 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 Defence Secretary Michael Fallon paid tribute to his nation's role in fighting the Taliban.

A total of 453 British troops and 2,349 Americans were killed.

"It is with pride that we announce the end of UK combat operations in Helmand, having given Afghanistan the best possible chance of a stable future," he said in a statement from London.

Many facilities such as pipelines, buildings, roads and even office furniture remain in place, with the US alone estimating $230 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.

"We're very proud of what we've accomplished here," added the officer, who was among the first Marines on the ground in autumn 2001, when a US-led coalition toppled the Taliban who had been in power since 1996.

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 1,800 soldiers.

"I'm certain we can maintain the security," he said Sunday. Asked about the departure of the NATO troops, he said: "I'm happy and sad. I'm happy because they are going to their home, I'm sad because they are friends." At Camp Leatherneck troops busied themselves with packing up, sorting out what medical equipment will go and what will remain.

Corporal Ruf Stevens, in charge of vehicle transport, returned to his hut with his assault rifle in one hand and a guitar he found in a dustbin in another. "I just think we got the job done. It's a dirty job but pride come with it," he said. The operational command centre, a small room in a wooden hut filled with surveillance screens and computers, is seeing out its final days.

Surveillance has picked up little in the way of insurgent activity in recent days as the yearly fighting season comes to an end.

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.

After the withdrawal, the Afghan National Army's 215th Corps will be headquartered at the 6,500-acre base, leaving almost no foreign military presence in Helmand.

The province, which produces 80-90 percent of the opium that helps finance the Taliban's insurgency, has seen fierce fighting this year, with Taliban and allied forces seeking to seize the district of Sangin from Afghan army and police. The battles have raised concerns about whether Afghan forces are truly able to hold off the Taliban without intelligence and air support from the United States and its allies.

Officials with the US-led coalition say the Afghan forces held their own this summer fighting season and did not lose any significant ground. "I'm cautiously optimistic they will be able to sustain themselves," said Brig Gen Daniel Yoo, the commander of Regional Command (Southwest). He said the success of the Afghan security army and police depended on leadership, continued development of logistics and confidence.

"They've got to want it more than we do," he said of Afghan forces that have been losing hundreds of soldiers and policemen each month in battles, assassinations and suicide attacks by insurgents.

"The guys right now are mostly looking forward to getting home," said Marine Lt John Pratson, 24, of Leonardtown, Maryland, as his team played touch football and lifted weights outdoors on the eve of the handover ceremony. "It's been a long hot summer," he said.

"It's empty now - when I got here, it was still bustling, so there were a lot of services around and people around," said Marine Capt Ryan Steenberge, whose taskforce was overseeing surveillance and security for the withdrawal and will be among the last troops out. "It's weird to see different pieces pull away."