Islamic State (IS) has claimed responsibility for an attack on Libya’s Foreign Ministry in Tripoli that killed three and injured around 20.

The December 25 attack on the ministry compound started with a car bomb exploding out front, followed by three gunmen opening fire as they tried to storm the building.

Two managed to enter the premises and blow themselves up, while the third was killed in a hail of gunfire with security guards.

Islamic State claimed responsibility for the attack, according to the SITE intelligence Group, which tracks the online activity of jihadist organizations.

Among the dead was Abdul-Rahman Mazoughi, a prominent leader of the Revolutionary Brigade militia group.

The United Nations Support Mission in Libya (UNSMIL) condemned the attack and stressed the need to "prevent terrorist groups from turning Libya into a haven or an arena for their crimes."

Libya has been in turmoil since the 2011 overthrow of dictator Muammar Qaddafi. The country is split between rival governments, each supported by various militia groups.

Based on reporting by AP, Reuters, and dpa