Britain's final flight carrying military personnel out of Afghanistan has left Kabul airport, the country's Defence Ministry said on Saturday.
Some 15,000 people - including troops, diplomats and Afghan allies - have been flown out of the country in the the past fortnight during the airlift, codenamed Operation Pitting.
However, hundreds of eligible Afghan citizens could not be evacuated and now face an uncertain fate under Taliban rule.
The departure marks the end of nearly two decades of UK military involvement in Afghanistan.
Prime Minister Boris Johnson said the it was “a moment to reflect on everything we have sacrificed and everything we have achieved in the last two decades”.
Some 457 British service personnel lost their lives in the Nato-led mission, which had been launched in November 2001 to oust the Taliban and the al Qaeda terrorist network.
Mr Johnson said: “20 years ago, in the wake of the 9/11 attacks, the first British soldier set foot on Afghan soil aiming to create a brighter future for the country and all its people.
“The departure of the last British soldiers from the country is a moment to reflect on everything we have sacrificed and everything we have achieved in the last two decades.
“The nature of our engagement in Afghanistan may have changed, but our goals for the country have not. We will now use all the diplomatic and humanitarian tools at our disposal to preserve the gains of the last twenty years and give the Afghan people the future they deserve.”
The Ministry of Defence earlier on Saturday confirmed the last civilian evacuation flight had left.
Defence Secretary Ben Wallace told troops on Twitter: “The UK should be very proud of what you have done. Every one of you have displayed the highest levels of professionalism and bravery.”
The Government said of the 15,000 people evacuated since the Taliban returned, 5,000 of those were British nationals and their families.
And more than 8,000 Afghans who helped the British effort as interpreters or in other roles, or who are otherwise vulnerable to persecution by the regime, were also able to flee to safety with their families.
The total number of Afghans brought to the UK under the Afghan Relocations and Assistance Policy (Arap) since it was set in April is now around 10,000 in total – double the number anticipated this year.
The UK has evacuated more people than any other country other than the US, the Government said, as both those in Afghanistan and co-ordinating the effort from the UK worked all hours to process evacuees.
The British embassy and Ambassador to Afghanistan Sir Laurie Bristow will temporarily relocate to Qatar, but the intention is to reopen an embassy in Kabul as soon as possible.
Ministers have stressed that the Arap scheme is not time-limited, and others deemed vulnerable, such as women and girls, can apply for the Afghan citizens’ resettlement scheme, which will take up to 20,000 refugees in coming years.
The Government said any Afghan people called forward for evacuation in recent days, but who did not make it out, would be guaranteed a place under the scheme.