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.
Mr Bolam’s MP in Craven Arms in Shropshire said he was “delighted” that the 63-year-old was back home safely.
It is thought the teacher’s release was secured by local political factions and that money changed hands.
Mr Bolam’s kidnapping had not been reported at the request of the Foreign Office and his family.
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, had been working in Libya for seven years.
He had 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.
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 may have been, our security correspondent added.
Charlie Cooper of counter-extremism think tank the Quilliam Foundation said the difference between the treatment of Mr Bolam and Mr Henning was “indicative of the huge difference between other jihadist groups and Islamic State”.
He told BBC Breakfast: “Islamic State is profoundly more extreme in its outlook and in its ideological motivations.”
The Crossroads of Special Operations