Picture: AP

Benghazi — Islamic State gunmen opened fire and later blew themselves up Wednesday at a courthouse complex in the Libyan city of Misrata, killing at least four people.

A top security official in Misrata, Col. Tarek al-Faqih, told reporters that three militants entered the complex shortly before noon, trading fire with guards before two of them detonated explosives belts. The third was shot dead.

The attack wounded 41 people. A prosecutor and two security officers were among those killed.

Al-Faqih said Wednesday's attack was likely motivated by revenge, after militias from Misrata drove IS from the coastal city of Sirte, some 150 miles (240 kilometres) to the east, last year.

In a statement circulated online, IS said it targeted "one of the most prominent strongholds" of the U.N.-backed government, which is based in the capital, Tripoli. Ghassan Salame, the U.N. envoy to Libya, condemned the attack.

Hundreds of IS militants are believed to have fled Sirte into Libya's desert interior. Libyan authorities last week announced the arrest of several IS militants and said they have issued some 800 arrest warrants linked to the extremist group.

Libya descended into chaos after a popular uprising in 2011 that toppled and later killed longtime dictator Moammar Gadhafi. The country is currently split between rival governments, each backed by an array of militias.

Associated Press