Mahmoud Shawse, a fighter for the Libya Dawn-allied 166 Brigade, had just stepped out to install a new surveillance camera when a car bomb detonated outside his base in Misrata.

Even as Mr. Shawse’s faction is locked in a prolonged struggle between two rival alliances for control of Libya, the twisted remains of the brown Hyundai in the base’s courtyard serve as a stark reminder of the growing reach of yet another force in the fractured country, the self-described Islamic State (IS).

“I never expected such an operation,” Shawse says of the March attack that wounded two of his colleagues and ripped open the walls of his office. “Even though such things are happening everywhere, in Syria and Iraq, this is my turf. This is Misrata.”

His remarks capture the zeitgeist of Misrata, a Mediterranean city that projects power well beyond its perimeter. Here, the population views itself as invincible and impenetrable by the likes of IS militants, who have settled in Sirte, the city where dictator Muammar Qaddafi was captured and lynched in 2011.

In his fight to hold on to power, the late dictator laid siege to Misrata for months, an experience that spawned scores of armed groups allied today in their backing of the Tripoli-based General National Congress (GNC). The scars of fierce fighting still show on the streets of this modern Sparta, where many residents still view themselves as warriors.

Before a series of bomb attacks in March and May hit their city, Misratis underplayed the IS threat, blaming Qaddafi loyalists for its rise. Some dismissed the IS slaughter of 21 Egyptian Copts in January as “propaganda,” filmed not on the coast of Libya but in Egypt, a major backer of Khalifa Haftar, the anti-Islamist Libyan general who commands the forces of the rival eastern alliance based in Al Bayda and Tobruk.

But attitudes have shifted. Now Misrata’s military and intelligence officers keep images of dead IS fighters on their phones. The group’s black banner – imprinted with the Muslim declaration of faith in white – is a trophy strewn on some coffee tables.

But nobody is taking any chances, as evidenced in the mushrooming of security cameras.

Keeping IS bottled up

For Misrata commanders like Mohammed Ihsaa, the goal is to keep any confrontation with IS centered on Sirte, a healthy 150 miles from Misrata.

“Daesh is in every city of Libya, even if in very small numbers,” he says, using a derogatory shorthand for IS. “But if we bring down Sirte then these smaller groups will disappear, as they will not have a base to sustain them.”

IS locked its grip on Sirte in February, raising its dark banner over the Ouagadougou complex where Mr. Qaddafi hosted lavish pan-African conferences. It also took the hospital, university, and radio station. Misrata forces now surround the city, much as they did in 2011.

Today there are sporadic skirmishes but no major offensive, Mr. Ihsaan says, lamenting the lack of Libyan unity and international support.

“IS is a tumor spreading in Libya and will spread on to Europe if left unchecked,” he warns. “They already have members in Europe, we have recordings of phone calls made to many European countries” by IS members caught in Libya.

In Sirte, neglect drew in jihadists

For Libyans, Sirte – roughly 300 miles from Sicily – “is the link between the east and the west. Sirte opens directly to the sea on the north and to the desert in the south,” explains Ismail Shukri, spokesman for the Misrata forces surrounding the city.

Large swathes of Sirte were destroyed in the 2011 fighting, and residents there felt neglected by the subsequent transitional governments. The security vacuum drew in North African foreign fighters, Libyan jihadists returning from the front lines of Syria and Iraq, and IS militants.

Libyan officials in Tripoli and Bayda put the number of IS backers in the oil-rich nation at a maximum of 500. One senior intelligence officer in Misrata, however, gave a far higher figure. “There must be at least 4,000,” he said, basing that estimate on the number of worshipers joining Friday prayers led by IS-vetted preachers in Sirte.

“The elders keep telling us not to come into the city, that their sons are with IS, and that they will handle the issue themselves,” adds the intelligence officer. "They want any fighting to take place in the desert, not in the city.”

Islamist allies

The first hard-line Islamist faction to take root in Sirte was Ansar al-Sharia, a rebel group involved in the 2012 Benghazi attack that killed a US diplomat. It later helped helped pave the way for IS.

“In the beginning, Ansar al-Sharia were the solution, not the problem," recalls the mayor of Misrata, Ali Busitta, who sits on a small committee of elders from Sirte and Misrata. "They would settle the problems between the families and the tribes. The problem began when foreigners came in."

Get the Monitor Stories you care about delivered to your inbox. By signing up, you agree to our Privacy Policy

Islamist Libyans argue that what distinguishes IS from Ansar al-Sharia – branded by the United Nations and Washington as a terrorist group – is their attitude to governance. Both want to see a strict interpretation of Islamic Law enforced in the conservative Muslim country, but only IS wants to take power.

"Today they work together because they are joined by a common enemy: Misrata in the west and General Khaftar in the east," says Khaled, a native of Sirte. "In Sirte, they have local support, because all people see is Misrata coming to attack them again, as they did in 2011.”