A British teacher who was being held hostage by militants in Libya has been released.

David Bolam, who worked at the International School in Benghazi, has been reunited with his family, the Foreign Office has said.

The teacher, who was flown back to the UK on Thursday night, was taken hostage earlier this year, according to reports.

The Foreign Office has said Mr Bolam is "safe and well after his ordeal" and that it has been supporting his family since he was taken.

Mr Bolam appeared in a video published online on August 28, in which he appealed to Prime Minister David Cameron to secure his release.

The video was claimed to have been released by a group who describe themselves as a Libyan faction called the Army of Islam, although it has not been officially confirmed who Mr Bolam's captors were.

A former colleague of the teacher told the BBC that Mr Bolam decided to stay in the country while others left amid growing violence because he "believed in what he was doing."

Libya has descended into chaos as armed groups which helped topple Muammar Gaddafi in 2011 turn their guns on each other in a struggle for political domination along with the country's oil resources.

Mr Bolam's release is believed to have been secured through the payment of a ransom, facilitated by local political factions, the BBC reported.

The Foreign Office, which does not support the payment of ransoms, has declined to comment on the report.

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."

The spokeswoman added: "We do not comment on the detail of hostage cases. The family have asked for privacy."

Charlie Cooper, of counter-extremism think tank the Quilliam Foundation, told BBC Breakfast that the treatment of Mr Bolam was "indicative of the huge difference between other jihadist groups and Islamic State."

Mr Bolam's kidnapping had not been reported at the request of the Foreign Office and his family.