Islamic State (IS) militants briefly entered the center of the western Libyan city of Sabratha overnight and reportedly beheaded 12 security officers before being forced to retreat.
The fighting started when local brigades — formerly among the many rebel groups that joined in an uprising that overthrew dictator Muammar Qaddafi in 2011 — attacked suspected IS hideouts 9 miles south of the city, Sabratha's municipal council said in a statement.
It said the militants then "took advantage of the security vacuum downtown and spread out all over the city" before forced out by the brigades.
Sabratha's mayor said late on Tuesday at least four brigade fighters had been killed and five injured in the clashes.
Local media reported that as many as 17 brigade members were killed, but no officials could be reached by Reuters to confirm the toll. The Associated Press reported the total number killed was 19, and that 12 security officers were beheaded when the militants briefly took over security headquarters in the city.
One official told AP that the headless bodies of the officers were then used to block roads.
Islamist militants have taken advantage of political chaos and a lack of central authority to establish a presence in Libya, with fighters loyal to IS seizing control in Sirte and staging attacks in several other cities.
A security source from the western city of Zintan said on Wednesday that authorities had agreed to treat the five wounded brigade members from Sabratha, a sign that Zintan and Sabratha may be prepared to cooperate in the fight against IS.
The two cities have been on opposite sides of Libya's post-Qaddafi conflict, with Zintan allied to the internationally recognised government now based in the country's far east and Sabrathan forces among those that support a rival government whose armed supporters seized the capital Tripoli in 2014.
On Friday, the United States carried out an air strike on a suspected IS training camp in Sabratha, killing nearly 50 people. Serbia's government said two Serbian diplomats kidnapped in Libya in November also died in the attack.
Watch the VICE News documentary:**Libya's Quiet War: The Tuareg of South Libya:**