A bomb exploded at the gate of the Moroccan Embassy in the Libyan capital early on Monday, causing some damage but hurting nobody, a security official said, only hours after gunmen attacked South Korea's mission in Tripoli.

Militants claiming loyalty to Islamic State said on Twitter they were responsible for both attacks, the latest strikes against foreigners, embassies or oil fields in Libya. It was not possible to verify the authenticity of the claims.

Islamic State militants have exploited chaos in the North African country where two governments allied to a host of armed groups fight for control four years after the ousting of Moammar Gadhafi.