Security forces in the western Libyan city of Sabratha said they had killed seven suspected Islamic State group fighters in a raid on a militant hideout on Wednesday.

Local brigades have been battling militants in Sabratha since they briefly overran the city centre last week and beheaded more than 10 brigade members.

That followed a US air strike on the outskirts of Sabratha on Feb. 19 in which more than 40 people were killed.

Sabratha is one of several Libyan cities in which militants loyal to Islamic State group have established a presence, taking advantage of the political chaos that has plagued Libya since Muammar Gaddafi was toppled in an uprising five years ago.

A spokesman for Sabratha's military council, Sabri Kshada, said Wednesday's raid took place about 20 km (12 miles) south of the city.

"Our forces were confronted by the militants and there was an exchange of fire," he said.

Three suspects escaped during the operation, and a Syrian fighter and a female Tunisian militant with a three-year-old son were detained, Kshada said.

Earlier, Kshada said that 46 members of local brigades had been killed in clashes with militants since last week. He could not give a toll for the militants, but said a "great number" had died.

The situation in the city was largely calm, he said, with state offices expected to reopen in the next few days.

Also on Wednesday, military forces in the eastern city of Benghazi said four troops had been killed in clashes with militants near the university.

Colonel Abdullah al-Shaafi said troops had advanced during fierce fighting in the Garyounis neighbourhood, south-west of the city centre.

A medical source said at least five people died and nine were wounded.

Military forces loyal to Libya's eastern government have made major gains over the past 10 days in Benghazi, where they have long been fighting Islamist militants and other armed groups in the city's streets.