The UK is closing its Libyan embassy amid escalating violence and fighting in the capital Tripoli.

Several UK embassy staff were evacuated earlier this week as fighting intensified near the British embassy compound, and now the Foreign and Commonwealth Office has announced that it will suspend activities at its consulate on Monday.

Ambassador Michael Aron said: "Reluctantly we've decided we have to leave and temporarily suspend embassy operations in Libya. We will be back as soon as security allows."

He added that embassy staff would continue to operate from neighbouring Tunisia.

Sporadic fighting between rival militias has spread northwards in Tripoli, with Islamist and nationalist factions trading artillery fire for three weeks. Several hundred people are believed to have been killed in fighting and Libya's government has effectively collapsed.

An FCO spokesman 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."

Several diplomatic evacuations have also been organised this week by the governments of France, Germany, the US, Japan and the Netherlands.

On Saturday, the Greek defence ministry transported embassy staff and almost 200 people from Libya on a navy frigate to a port near Athens following the deteriorating level of security in Tripoli.

Mustafa Avocat, a Greek-Libyan accountant, told the Associated Press: "We were hearing explosions all the time, but the fighting was on the outskirts of Tripoli.

"Things are getting worse. The power is cut five to seven hours every day. There are water cuts too and the shops are closed. It's not somewhere you can raise a family."

Poland's foreign ministry said it has evacuated all of its diplomats along with two dozen Poles and citizens of two other countries.

On Friday, Tunisia closed its main border crossing with Libya after thousands of stranded Egyptians and foreign nationals fleeing intense fighting tried to break through the passage from Libya, the Tunisian news agency reported.

The current violence is the worst Libya has seen since the downfall of Muammar Gaddafi in the country's 2011 civil war. The country's health ministry said 214 people have been killed in the fighting and a further 980 wounded.

Earlier this week, Islamic militants targeted army bases in Libya's second largest city Benghazi, claiming control of the city.