Suspected Islamic State (Isis) militants have detonated a bomb outside the Spanish Embassy in Libya, causing damage to the building but no injuries.

The blast went off early in the morning (21 April) near the outside wall of the diplomatic compound in Tripoli's Ben Achour district, which has been shut since last summer, when Madrid pulled its entire staff from Libya due to deteriorating security.

Several vehicles parked outside were damaged in the explosion, which was reportedly heard across the neighbourhood.

Some Twitter accounts connected to IS's local branch claimed responsibility for the attack, which seems to have been a symbolic action against UN-brokered talks between Libya's two rival governments.

Charlie Winter, a researcher for the London-based counter-extremism Quilliam Foundation, tweeted:

Local officials confirmed the jihadist group was behind the bombing.

"Islamic State extremists concealed an explosive device near an exterior wall of the Spanish embassy building in Tripoli, which caused some material damage to it and to neighbouring buildings," local official Issam Naas told AFP.

In recent months, IS has exploited the years of chaos that followed the overthrow of late dictator Muammar Gaddafi to take command of the country.

Adopting a strategy similar to that the group used in Syria, it has won the allegiance of local Sunni extremists and subsequently infiltrated several coastal cities.

Libya is locked in a three-way power-struggle pitting forces loyal to the internationally recognised government against Libya Dawn, an umbrella group including radical and moderate Islamists that controls Tripoli and has formed a rival administration, and IS affiliates.

The attack on the Spanish embassy was IS's third against a diplomatic mission in the Libyan capital this month. Earlier in April, gunmen opened fire on the South Korean embassy in the city, killing two Libyan guards. Hours later the Moroccan diplomatic compound was damaged by a bomb blast.

In February the Iranian embassy was hit by a double bombing, also claimed by IS, while several people were wounded in another bomb attack against the Algerian mission a month earlier.

The spree of violence seems to be targeting countries involved in peace talks to resolve the Libyan conflict.

The negotiations, which have been sponsored by UN Secretary-General Ban Ki-moon of South Korea, are centred on a plan laid out by UN envoy Bernardino Leon, who is Spanish, and resumed last week in Morocco after an earlier round in Algeria.