TRIPOLI (Reuters) - Islamic State militants briefly entered the centre of the western Libyan city of Sabratha, beheading 11 members of local security forces and killing another six in overnight clashes before retreating, local authorities said on Wednesday.

Islamist militants have taken advantage of political chaos and a lack of central authority to establish a presence in Libya, with fighters loyal to Islamic State seizing control in Sirte and staging attacks in several other cities.

The fighting in Sabratha started when local brigades - formerly among the many rebel groups that joined in an uprising that overthrew Muammar Gaddafi in 2011 - attacked suspected Islamic State hideouts 15 km (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”.

Sabratha’s mayor, Hussein al-Thwadi, told Reuters that six members of the local brigades had been killed in clashes on Tuesday evening and 11 more were beheaded when militants entered the security directorate building in the city centre overnight before the brigades forced them out.

Late on Wednesday the Deterrence force, an armed brigade based in Tripoli that has a counter-terrorism role, said it had arrested three senior Libyan Islamic State members in a suburb of the capital, including Sabratha commander Mohamed Saad Altajouri.

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 Islamic State.

The two cities have been on opposite sides of Libya’s post-Gaddafi 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.

Sabratha mayor Thwadi said local towns and cities including Zawiya and Surman had offered support against Islamic State, and that Sabratha had asked Zintan and two other towns to cut off militants’ supply routes along desert roads.

On Friday, the United States carried out an air strike on a suspected Islamic State training camp on the outskirts of Sabratha, killing nearly 50 people. Serbia’s government said two Serbian diplomats kidnapped in Libya in November also died in the attack.

It was the second U.S. air strike in three months against Islamic State in Libya.