ISIS affiliates briefly took over a security headquarters in the Libyan city of Sabratha. This photo shows rebel fighters patrol the road leading to the western Libyan town of Zuwara, east of the port of Sabratha on Aug. 18, 2011. Getty Images/FLORENT MARCIE/AFP

Islamic State group affiliates in Libya beheaded 12 security officers after briefly taking control of their headquarters in the western city of Sabratha late Tuesday, the Associated Press (AP) reported. The militant group, also known as ISIS, was driven out early Wednesday morning, two city security officials reportedly said.

The gunmen "exploited a security vacuum" by deploying in the city center as the military was occupied conducting raids elsewhere, Taher al-Gharabili, head of Sabratha Military Council, told the AP.

Another official, who did not want to be named, said that ISIS militants used the headless bodies of the security officials they killed to block roads, the AP reported. The headquarters was reportedly in control of ISIS for about three hours. The official also said that the death toll from the clashes between the military and ISIS fighters had reached 19.

The incident comes just days after American forces carried out their first airstrikes of the year on one of the militant group’s bases in Sabratha. A Tunisian leader of ISIS and two Serbian embassy workers who had been kidnapped by the extremist organization were among the 49 fatalities in the northwestern coastal city.

Libya’s chaos, which began after the fall of dictator Moammar Gadhafi five years ago, has given rise to the ISIS affiliate’s control of several cities.

“Conflict zones and failed states necessarily attract violent extremists — and Libya is the perfect candidate for a new safe haven for jihadist fighters. The phenomenon of foreign fighters has enhanced this threat, as young extremists are provided with an ideal destination for waging violent jihad,” according to a report by the Soufan Group, an intelligence and risk consultancy.

“Given geography, expansive territory, extensive oil reserves and its history with violent jihadist networks, a failed state in Libya could be disastrous for North Africa and Europe, as well as the broader international community,” the consultancy said.