The Foreign Office is closing its embassy in Tripoli amid escalating violence in the Libyan capital.
Many staff members were evacuated earlier this week and British citizens have been told to leave the country immediately.
The Foreign and Commonwealth Office (FCO) is helping British nationals leave but warned it will not be able to provide assistance after operations are suspended on Monday.
Only the ambassador and core staff remain in the building and are expected to return to the UK in the coming days.
Fierce fighting between rival militias has spread northwards through Tripoli, into the area where the consulate is situated, and shots were fired at embassy staff in an attempted carjacking last week.
An spokesman for the FCO said: “The protection of our staff is paramount, and we assess that the current environment in Tripoli does not allow us to operate safely. We have therefore decided temporarily to relocate UK-based staff from the country.”
Libya has descended into chaos since the overthrow of Muammar Gaddafi during the Arab Spring in 2011.
The rebels were supported by British and French air strikes in the supposed interests of the Libyan people but they were soon accused of carrying out massacres themselves, with at least 42 protesters killed in Tripoli last November.
The former Prime Minister, Ali Zeidan, was voted out of office earlier this year and has fled the country as the Government struggled to fill the power vacuum left by Gaddafi’s downfall.
Rival militias struggling for power and wealth have now created a state of lawlessness in areas of the country.
The US has already closed its embassy and France and Greece are among other countries to have evacuated citizens.
Violence broke out at the border crossing of Ras Jdir on Friday as police shot in the air and fired tear gas to stop a group of Egyptians who tried to storm the border in their desperation to flee Libya.
There are believed to be between 100 and 300 British citizens in the north African country.
The ambassador, Michael Aron, said the decision to leave was taken reluctantly.
Writing on Twitter, he added: “Fighting has spread to where we live in Suraj and the risk of getting caught in the crossfire is too great. Very sad.”
On Wednesday, British Airways suspended flights to and from Tripoli until Tuesday due to the deteriorating security situation at the country's main international airport.
An FCO spokesman added: “Fighting has intensified in Tripoli, including around the British embassy compounds. In the light of the deteriorating security situation, we are taking steps temporarily to suspend operations at the British embassy in Tripoli after the planned assisted departure of British Nationals.
"The UK government has changed its travel advice to reflect the ongoing security situation. We advise against all travel to Libya and urge British nationals in Libya to leave through commercially available means.”
Additional reporting by PA
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies