Three more posted outside the empty UAE compound were wounded in the second, a senior UAE official told AFP in Abu Dhabi.

Both governments are considered hostile by the Islamist militias which seized Tripoli in August in an offensive during which UAE fighter jets allegedly carried out strikes against them from neighbouring Egypt.

Abdullah bin Zayed Al-Nahyan, UAE foreign minister, denounced the attack against his country's embassy as a "terrorist act" and blamed it on Fajr Libya and Ansar al-Sharia.

The US has blacklisted Ansar al-Sharia as a terrorist group for its alleged role in a deadly 2012 attack on the US consulate in the eastern city of Benghazi, where it is largely in control.

Fajr Libya (Libya Dawn) is a coalition of Islamist militias which seized Tripoli in August after weeks of deadly fighting with a nationalist group.

Nahyan, in a statement carried by state news agency WAM, said the bombing "badly damaged" the embassy and wounded three people in the area.

Guards wounded

The first bomb went off in a car park close to the Egyptian embassy, shattering several of its windows, the AFP correspondent reported.

The second went off minutes later just outside the UAE mission compound, wounding three non-Emirati guards, the official in Abu Dhabi said.

"This is an indication of the state of lawlessness in the Tripoli area," the official said, speaking on condition of anonymity.

He said the blast showed the need for greater support of Libya's internationally recognised government, which took refuge in the remote east of the country after the militia takeover of Tripoli.

"The unruly condition that we are seeing will deteriorate further if the extremist militias continue to control the Libyan capital," he said.

The recognised government's Foreign Ministry said such attacks were the result of "the absence of the legitimate state in Tripoli, now in the hands of Islamist militias which use the threat of arms against citizens, public institutions and diplomatic missions".

A Libyan security official, who works for a unit in charge of protecting embassy and diplomatic staff, said police were investigating the bombing and studying footage from CCTV cameras.

He also linked the attacks to "support" by the governments of Egypt and the UAE for Khalifa Haftar, a former general who has launched an offensive on Islamist militias in Benghazi.

"This is not the first time that the embassies of those two brotherly countries are targeted ... due to their continued support for Haftar's forces," he said.

Egyptian denunciation

The Foreign Ministry in Egypt, which has denied participating in the raids, also denounced Thursday's "terrorist bombings".

Egypt closed its embassy in Tripoli in January and the UAE followed suit in May as security conditions in the city deteriorated.

Three years after Muammar Gaddafi was toppled and killed in a NATO-backed revolt, Libya is run by rival governments and parliaments.

While the conservative factions have set up their own government and parliament in Tripoli, the elected parliament and administration of Prime Minister Abdullah al-Thinni has been compelled to operate out of Tobruk.

Both sides have routinely accused each other of seeking support from neighbouring regional powers, and many embassies and embassy staff have left Tripoli.

International efforts led by the UN to mediate between the rival factions have so far failed to broker a ceasefire or bring the main armed actors to the negotiating table.