The US and Britain have both announced that they are withdrawing some diplomatic staff from Libya, amid security concerns over a recent flare-up in political unrest.

Tensions have risen in Libya since former rebels besieged two ministries at the end of last month in a row over a law that would ban officials who served under Muammar Gaddafi, the country's former leader, from holding office.

"In light of the current unsettled conditions around major anti-government demonstrations in Tripoli, the under secretary for management has approved the ordered departure of non-emergency personnel from Libya," said US State Department deputy spokesman Patrick Ventrell.

"A handful of our staff members have, indeed, departed Libya. Our embassy in Tripoli is still open and still functioning."

Earlier, a spokesman for the British Foreign Office said that the UK's embassy in the Libyan capital was "temporarily withdrawing a small number of staff, mainly those who work in support of government ministries which have been affected by recent developments".

British Ambassador Michael Aron tweeted that "despite rumours the British embassy in Tripoli is open for business".

But the British Council cultural agency said separately that it was closing its Libya office until next week for the same reasons.

It promised to make up any of the English language classes that students have missed.

Gunmen surrounded the Libyan foreign ministry on April 28 and the justice ministry two days later to demand the passing of a law excluding Gaddafi collaborators from office.

Benghazi violence

There has also been violence in Libya's second city Benghazi, the cradle of the 2011 uprising that toppled Gaddafi, with bomb attacks on Friday damaging two police stations, although there were no casualties.

In September, an attack on the US consulate in the city left Ambassador Chris Stevens and three other Americans dead.

Britain, France and the US issued a joint statement on Wednesday calling on "all Libyans to refrain from armed protest and violence during this difficult time in the democratic transition".

On Thursday, the US State Department issued a travel warning, saying it "strongly advises against all but essential travel" to Tripoli and all travel to Benghazi, Bani Walid and southern Libya, including border areas and the regions of Sabha and Kufra.

On April 23, a car bomb exploded outside the French embassy, wounding two French guards and causing extensive damage.

The French government reduced the number of personnel at the mission, which continues to function despite the damages.

Meanwhile, the French school in Tripoli planned to stay closed until security around its building can be guaranteed, its directors said.

The German embassy has closed its doors, and its staff have been moved to secure quarters elsewhere in Tripoli.

As far back as January, the UK referred to a potential threat on its embassy in Tripoli and called on its citizens to leave Benghazi after identifying a "specific and imminent threat to Westerners".