Fighters loyal to the Islamic State of Iraq and the Levant (ISIL) have claimed responsibility for an attack on the Iranian embassy in the Libyan capital Tripoli.

Two bombs exploded at the gate of the Iranian diplomatic complex on Sunday, although nobody was hurt in the blast, Libyan security officials said.

"Two devices were laid, one exploded first and then the other. The point of the second bomb was to create confusion," Colonel Jumaa al-Mashri from the National Security Agency told Tripoli-based al-Nabaa television. 

The Associated Press news agency reported that the Iranian ambassador was not in the residence during the attack.

Iran's official IRNA news agency also confirmed the blasts, adding that Iran had previously suspended operations at its embassy. The building had been vacant since 2012.  

The building complex lies in a central district of Tripoli, where several diplomatic missions are located.

Witnesses told AFP news agency that windows at the nearby Ukrainian embassy were shattered by the impact of the blasts.

The attack on Sunday was the latest to target a diplomatic mission in Tripoli, where most embassies have been shut since summer 2014 as rival armed militias battled for control of the city.

Al Jazeera's Hoda Abdel-Hamid, who is reporting from Djerba in neighbouring Tunisia, said that while damage to the attack was minimal, it carried a "symbolic message."

"The message here is that ISIL is on the ground and it is spreading across the country." 

In January, ISIL also claimed responsibility for an attack with explosives that targeted the empty Algerian embassy in Tripoli, wounding a security guard and two passers-by.

ISIL has been gaining ground in Libya, feeding on chaos that has engulfed the country since dictator Muammar Gaddafi was toppled and killed in a 2011 NATO-backed uprising.

The country is awash with weapons and has two rival governments and two rival parliaments, with authorities unable to rein in powerful armed groups battling for power and to control the nation's oil wealth.

Source: Al Jazeera and agencies