CAIRO -- Islamic state of Iraq and Syria (ISIS) affiliates in Libya briefly took over the security headquarters in the western city of Sabratha, killing and beheading 12 security officers before being driven out early Wednesday morning, two city security officials said. The incident highlighted the enduring presence and unpredictable striking power of the local ISIS militants in this strategic city which serves as a hub for migrants heading to Europe.

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

A second security official said that the militants used the headless bodies of the officers they killed to block the roads leading to the security headquarters - which they occupied for about three hours. The official, who spoke on condition of anonymity because he was not authorized to speak to the press, said the total number of officers killed in the occupation and ensuing clashes reached 19.

Sabratha has become the latest Libyan power center for the local ISIS affiliate. Last week, U.S. airstrikes killed dozens of suspected militants in the city along with two Serbian hostages kidnapped last year.

Libya's chaos, five years after the uprising that led to the ouster and killing of longtime autocrat Muammar Qaddafi in 2011, has paved the way for the ISIS affiliate to take control of several cities. The divided country is ruled by two parliaments: an internationally recognized body based in the eastern city of Tobruk and a rival government, backed by Islamist-allied militias, that controls the capital, Tripoli.

Get Breaking News Delivered to Your Inbox

The United Nations brokered a deal last year to unite the country's various factions. A new unity government is awaiting endorsement by the eastern parliament. The unity government could pave the way for an international military intervention against ISIS. The extremist group has previously taken over the city of Darna, before being driven out, and still controls the central city of Sirte, Gadhafi's home town.