Attack came two days after the group claimed responsibility for a double suicide bombing that killed more than 40 people in the eastern town of Qubbah
Militants claiming loyalty to ISIL said they were behind Sunday's twin bomb attacks on the residence of the Iranian ambassador in the Libyan capital and a rocket strike on the eastern Labraq airport.
The attack on the ambassador's residence came two days after the group claimed responsibility for a double suicide bombing that killed more than 40 people in the eastern town of Qubbah, one of the worst attacks on civilians since a 2011 uprising toppled Muammar Gaddafi.
Western powers are concerned that Libya is emerging as a thriving battleground for militants loyal to ISIL, which controls large areas of Iraq and Syria. Islamist fighters have exploited instability as two rival governments fight for control of territory.
The group has stepped up attacks since Egypt launched air strikes on suspected militant targets in the eastern Libyan city of Derna on Monday, a day after Islamists released a video showing the execution of a group of Egyptian Coptic Christians.
On Sunday, two bombs exploded at the gate of the Iranian ambassador's residence in central Tripoli. Iran's official IRNA news agency confirmed the blasts and said there had been no casualties, adding Iran had already suspended operations there.
"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.
A Reuters reporter at the scene saw the second device exploding some 30 minutes after the first. Minor damage could be seen at the gate.
"Soldiers of the ISIL caliphate targeted the Iranian embassy in Tripoli," the group said in a statement posted with pictures of a flame on Twitter.
The militants also claimed responsibility for a Grad rocket attack on Labraq airport, announced by officials on Saturday. No one was hurt. The airport is the main gateway into eastern Libya and Bayda, seat of the internationally recognised prime minister, Abdullah Al Thinni.
His government and the House of Representatives, elected in June, have been working out of the east since a faction called Libya Dawn seized Tripoli in August, reinstating the previous assembly and setting up a rival administration.
Last month, militants claiming affiliation with ISIL stormed the Corinthia luxury hotel in Tripoli, killing five foreigners and at least four Libyans.
Supporters of the group have also taken over government and university buildings in Sirte, a central city and birthplace of Gaddafi, according to residents.