British teacher David Bolam has been released after being held hostage by militants in Libya since May.
The Foreign Office said Mr Bolam, who taught at the now-closed International School Benghazi, was “safe and well” and had been reunited with his family.
His kidnapping had not been reported at the request of the Foreign Office and his family.
It is thought his release was secured by local political factions after a ransom was paid.
BBC world affairs correspondent Caroline Hawley said she understood demands for a ransom had been made to the school and that money was handed over to secure his release.
She said it was “unclear” how much money was paid and who paid it, but the Foreign Office was not involved in the negotiations.
Mr Bolam, who flew back to the UK on Thursday night, appeared in a video posted online on 28 August.
Wearing a white T-shirt and sitting in a concrete room, he appealed to UK Prime Minister David Cameron to secure his release.
Speaking in English, he said he was in good health and had been held “a very long time.”
There had been fears Mr Bolam faced the same fate as British hostages held by Islamic State (IS) militants operating in Syria and Iraq, BBC security correspondent Gordon Corera said.
In recent weeks, IS has released videos showing the apparent beheading of two US journalists, James Foley and Steven Sotloff, and British aid workers David Haines and Alan Henning.
However, little is known about the group which held Mr Bolam and what their demands might have been, our correspondent added.
Caroline Hawley says Benghazi – where the uprising against Muammar al-Gaddafi began – is now a chaotic place “where Islamist militias and criminal gangs abound”.
A Foreign Office spokeswoman said: “We are glad that David Bolam is safe and well after his ordeal, and that he has been reunited with his family.
“We have been supporting his family since he was taken.”
Ged O’Connor Challis taught at the international school along with his wife Siobhan until December 2013, so had left by the time Mr Bolam was abducted in May.
He said he spoke to Mr Bolam on the phone on the morning he was kidnapped, and school staff later said “one of the local militias had grabbed David as he went out shopping”.
Mr O’Connor Challis, who now lives in Manchester, said Mr Bolam stayed in Libya when other staff left because he “believed in what he was doing”.
“He is single-minded and stubborn,” he said.
“He is a very bright person. He is an English teacher – one of the best I have ever met.”
Teachers had wanted to stay at the school, Mr O’Connor Challis said, but a “massive gunfight” in November 2013 and the fatal shooting of teacher Ronnie Smith in December were part of growing violence which convinced many to leave.