The UK Government has received assurances from the Taliban that anybody wishing to leave Afghanistan after August 31 will be allowed to do so.
British troops have already left Kabul and US military personnel will be out of Afghanistan before the August 31 deadline set by US President Joe Biden.
But there have been fears over the potentially thousands of Afghans who may have been eligible for resettlement schemes, who could not make it to Kabul airport for evacuation or were not processed in time.
Prime Minister Boris Johnson said on Sunday that if the Taliban regime wanted diplomatic recognition and aid funding, they would have to ensure “safe passage” for those who want to leave.
And in a joint statement with the US and more than 90 other countries, it was confirmed that the Taliban had said anyone who wished to leave the country could do so.
The joint statement said: “We have received assurances from the Taliban that all foreign nationals and any Afghan citizen with travel authorisation from our countries will be allowed to proceed in a safe and orderly manner to points of departure and travel outside the country.”
It comes after 15,000 people were evacuated from Afghanistan by UK troops over the course of nearly two weeks in Operation Pitting, which is believed to be the largest evacuation mission since the Second World War.
British ambassador to Afghanistan Sir Laurie Bristow, who had remained in the country and relocated the embassy to Kabul airport to process as many evacuees as possible, arrived back in the UK on Sunday.
He vowed to continue to help British nationals and Afghans who remain in the country and still need help.
Speaking on the runway at RAF Brize Norton in Oxfordshire, he said: “We’ve had to leave Afghanistan for now and the embassy will operate from Qatar for the time being.
“We will continue to stand by the people of Afghanistan, working on humanitarian, diplomatic and security work, and above all bringing to the UK Afghans and British nationals who still need our support, and we will be putting pressure on the Taliban to allow safe passage for those people.
“We will reopen the embassy as soon as we can. We will do everything we can to protect the gains of the last 20 years and above all to help the Afghan people achieve the security and the peace that they deserve.”
Vice Admiral Ben Key, Chief of Joint Operations, who commanded Operation Pitting, admitted there was a “sense of sadness” that not all could be saved.
He said: “Whilst we recognise and I pay testament to the achievement of everything that has been achieved by coalition forces, but particularly the British contingent, over the last two weeks, in the end we know that there are some really sad stories of people who have desperately tried to leave that we have, no matter how hard our efforts, we have been unsuccessful in evacuating.”
He added: “There has been a phenomenal effort achieved in the last two weeks. And I think we always knew that somewhere we would fall just short.”
After official advice earlier in the week changed to advise people to stay away from Kabul airport due to the threat of a terrorist attack, ministers said anyone who could reach a third country could be processed and flown to the UK from there.
But there were concerns the Taliban would not allow this, amid reports of roadblocks.
Among those stuck in Afghanistan was the wife of a British shopkeeper who was killed in the terror attack on Kabul airport on Thursday.
Zohra Popal, 23, broke down in tears as she described the pain of losing her father, Musa Popal, and begged the Government to help bring her mother home.
She said the family feel “ignored” by the Foreign, Commonwealth, and Development Office, which has not made contact since news of his death was confirmed.
Mr Popal, 60, was among three British citizens, including a child, who were killed in the suicide attack.
Mohamed Niazi, 29, an Uber driver from Aldershot, Hampshire, was also among the victims.
Ms Popal said she fears for the life of her mother Saleema, 60, and members of her family who she believes could be targeted by the Taliban.
The attack killed more than 180 people, including 14 US service personnel.
On Sunday, Mr Biden travelled to meet the families of those who had been killed.
In a video uploaded to Twitter on Sunday, Mr Johnson praised the more than 1,000 military personnel, diplomats and officials who took part in the operation in Afghanistan.
He said: “UK troops and officials have worked around the clock to a remorseless deadline in harrowing conditions.
“They have expended all the patience and care and thought they possess to help people in fear for their lives.
“They’ve seen at first hand barbaric terrorist attacks on the queues of people they were trying to comfort, as well as on our American friends.
“They didn’t flinch. They kept calm. They got on with the job.
“It’s thanks to their colossal exertions that this country has now processed, checked, vetted and airlifted more than 15,000 people to safety in less than two weeks.”
Meanwhile, officials said a US airstrike has targeted a vehicle carrying “multiple suicide bombers” from the affiliate of the so-called Islamic State, Isis-K, in Afghanistan before they could target the US military evacuation at Kabul airport, officials said.