The final UK service personnel have left Kandahar Airfield in southern Afghanistan to return home, the Ministry of Defence has said.
They departed for the UK on Sunday afternoon, 13 years after the military arrived in the region.
Only a few hundred British troops now remain in Afghanistan.
The last combat troops withdrew from Camp Bastion in a huge airlift operation four weeks ago.
The MoD said the only UK military servicemen and women remaining in Afghanistan were in advisory, logistical and support roles, helping the Afghan army.
Around 100 of these were working at the Afghan Military Academy near Kabul, it said.
Servicemen and women watched on Sunday as the Union flag was lowered at Kandahar Airfield to mark their departure.
Personnel from the RAF's 904 Expeditionary Air Wing boarded a C17 aircraft bound for the UK.
They were joined by colleagues from the Joint Force Support Unit, which was responsible for aiding military operations in Afghanistan.
Defence Secretary Michael Fallon said: "Britain's armed forces can take great pride in the completion of their deployment to southern Afghanistan.
"Thanks to their courage and dedication, the country has the best possible chance of a stable future.
"Our departure from Kandahar airfield therefore is a historic milestone.
"Looking to the future, the UK's focus now switches to training the Afghan Army's future officers and providing continuing support to the security ministries in Kabul."
Lieutenant Colonel Rachel Parr, who oversaw much of the redeployment work, said that "logistic challenges don't come much bigger or more complex" than the gradual exit.
"The redeployment from Operation Herrick (British operations in Afghanistan) has been two years in the planning and execution by a host of people and organisations, military, civil service and contractors, here, back in the UK and in Germany," she explained.
"To be on the last deployment at the theatre end of all this work, which represents the efforts of so many people, has been an immense privilege."
A total of 453 British forces personnel or MoD civilians have died while serving in Afghanistan since the start of operations in October 2001.