The western Libyan city of Sabrata has been liberated from Islamic State militants, news agency LANA quoted Libya's Defence Ministry as saying Friday.
On Tuesday, Islamic State militants launched an attack on Sabrata, seizing the police headquarters and central areas of the city.
Six policemen and five extremists were killed during clashes that erupted following the attack, Libyan Cloud News Agency reported earlier this week.
Most of the extremists who carried out the attack are believed to be Tunisians, while some are Libyans, local military council chief Taher al-Gharabi told Libya TV earlier this week.
There are mounting concerns that Islamic State is boosting its presence in Libya, which was thrown into chaos after the NATO-backed ouster of longtime dictator Moamer Gaddafi in 2011.
Islamic State already controls a long stretch of coastline around the city of Sirte, about 500 kilometres east of Tripoli.
Last week, the US launched an airstrike against Islamic State forces in the city, killing scores.
The airstrike targeted Noureddine Chouchane, a Tunisian operative linked to two major attacks in Tunisia last year.
Sabrata, located 80 kilometres from the Tunisian border, is seen as a hotbed for foreign nationals who have joined Islamic State.