A UN aid worker is among four British nationals to have been released from detention in Afghanistan.
The Foreign Office said "we welcome and appreciate" the release of the men, held over allegedly breaking the country's laws.
Two of the group were named online as Kevin Cornwell, a 54-year-old UN aid worker, and Miles Routledge.
The Presidium Network, which has been supporting some of the group, said two men would likely need medical help.
The Foreign Office said the UK government "regrets this episode".
It said: "On behalf of families of the British nationals, we express their apologies to the current administration of Afghanistan for any violations of the laws of the country."
It is understood the men travelled to the country for personal or professional reasons.
The Foreign Office did not provide any detail on the identities of those released, what specifically they were detained for, their whereabouts, or their health.
The Presidium Network, a UK non profit organisation that supports people in crisis, said one of those freed was Mr Cornwell - a paramedic from Middlesbrough who had been working for UNHCR in Kabul when he was detained in January.
The second person it named as being freed - Mr Routledge - is a former Loughborough University student from Birmingham, known for travelling to dangerous countries and posting about it on social media.
In August 2021, he was evacuated from Afghanistan by the British armed forces in the month that the Taliban swept back into power in the country. He said at the time he was "exhausted but relieved" and thankful to those who had helped get him out.
He chose to travel to Afghanistan because he enjoys "dark" and "extreme" tourism, he said.
The organisation is representing Mr Cornwell and his family, along with a second unnamed man.
They have "started their journey back to the UK" and efforts to reunite them with their families have begun, it said.
A week ago, the Presidium Network posted on X that Mr Cornwell remained "seriously ill" and the health of a second Briton had also deteriorated.
Its co-founder, Scott Richards, told BBC News Mr Cornwell had contracted sepsis multiple times and the fear the two men may not come home was "very real".
He said: "The relief we feel, and the relief of the families is indescribable, just knowing the men are on a plane home.
"We are all deeply thankful for the efforts of the Foreign Office as well, and we are pleased the Taliban finally permitted these men their liberty, and for their families to be reunited."
Mr Cornwell's detention was understood to be over a weapon that had been in a safe in his room.
Mr Richards told the BBC earlier this year the weapon was being stored with a licence issued by the Afghan interior ministry but that the license was missing.
Mr Richards posted on X (formerly Twitter) on Tuesday: "Mr Cornwell and the three other British nationals which includes Miles Routledge have been released and have left Afghanistan. They are coming home!
"Thank you to everyone for their support of these men during this difficult period. We are all relieved."
He added their families "will likely need some time together before speaking with the media, and two of the men will likely need medical assistance".