David Bolam "is safe and in good health" and was reunited with his family, said the Foreign Office, without providing further details.
Abducted May 19 in Benghazi in eastern Libya, he was a teacher at the European School in the city, of which he was one of the leaders.
His captors had called immediately Libyan Warden and demanded a ransom, according to a source at the school speaking on condition of anonymity. An American teacher from the same school was assassinated in December in Benghazi.
Appearance in a video of the "Army of Islam"
The American site monitoring Islamist websites SITE, detected a video posted on YouTube last month, when David Bolam asked the British Prime Minister David Cameron to promote its release.
This video, apparently recorded in August, had been published by a group calling itself Jeish-al-Islam (Army of Islam), but SITE was not able to authenticate due to a lack of information.
Libya is in chaos and delivered militias since the overthrow and death in 2011 of dictator Muammar Gaddafi. Benghazi, cradle of the uprising against Gaddafi stronghold of radical Islamist groups, is now regularly the scene not only fighting but also of murders of members of the security forces, activists and journalists.