Libyan officials say assault, which killed three guards in Tripoli, was aimed at freeing prisoners.

The Islamic State of Iraq and the Levant (ISIL) group has claimed responsibility for an attack on a prison in the Libyan capital of Tripoli.

Libyan officials from the legally-installed government in Tripoli said Friday’s attack was an attempt to free prisoners held on terror charges at the facility, which is located at the now closed Mitiga airport.

The fighters used hand grenades and explosive belts. The Special Deterrence Force in charge of the prison said all the attackers were killed in an ensuing gunbattle. They did not provide specific casualty figures.

“The attack was foiled after an hour of clashes … and the prison is now under the full control of the Special Deterrence Force.” military officials said in a statement, the DPA news agency reported.

Libya’s Channel TV, citing an unnamed security official, said six attackers were killed.

In a statement posted on Twitter earlier in the day, ISIL’s self-styled Province of Tripoli said its fighters had stormed the prison to free “Muslim prisoners”.

Mitiga airport, about 11km east of Tripoli, has been shut since November 2014 because of fighting between rival militias.

ISIL has established a foothold in Libya’s coastal city of Sirte, taking advantage of the anarchy in the country since the overthrow in 2011 of longtime leader Muammar Gaddafi.

Libya now has two rival governments and parliaments, backed by competing militias.

The United Nations is trying to broker a deal between the rivals to end the civil strife in the oil-rich country.