Libya Dawn fighters look toward Islamic State militant positions near the coastal city of Sirte, Libya. (Goran Tomasevic/Reuters)

As the Islamic State scores new victories in Syria and Iraq, its affiliate in Libya is also on the offensive, consolidating control of Moammar Gaddafi’s former home town and staging a bomb attack on a major city, Misurata.

The Islamic State’s growth could further destabilize a country already suffering from a devastating civil war. And Libya could offer the extremists a new base from which to launch attacks elsewhere in North Africa.

The Libyan affiliate does not occupy large amounts of territory as the Islamic State does in Syria and Iraq. But in the past few months, the local group has seized Sirte, the coastal city that was Gaddafi’s last redoubt, as well as neighborhoods in the eastern city of Derna.

A key reason for the Libyan affiliate’s expansion is the chaos that has enveloped this oil-rich nation since the 2011 Arab Spring revolt. The country has two rival governments and is rent by fighting between militias that emerged from the anti-Gaddafi struggle.

Although the Islamic State claims allies in many countries, the Libya branch is especially close to the main organization. Its core fighters in Libya are veterans of the Syrian civil war.

Security experts estimate there are as many as 3,000 fighters loyal to the Islamic State in Libya. The country has become one of the primary locations to train with the group outside of Syria and Iraq. Volunteers from Tunisia, Algeria, Egypt, Saudi Arabia and other countries have flocked here to fight with the extremists and other jihadist organizations. The Islamic State also has succeeded in pulling away members of other Libyan extremist groups.

In the latest signs of their growing strength, Islamic State fighters last month seized the airport and an adjacent air base in Sirte, where they have controlled most government institutions since February. The militants also took over the nearby headquarters of a mammoth network of pipes that pump fresh water to Libyan cities.

Then, on May 31, the militants dispatched a Tunisian suicide bomber to Misurata, 170 miles west of Sirte. He rammed his vehicle into a major security checkpoint, killing five.

Five days later, Islamic State fighters captured the town of Harawah, 46 miles east of Sirte.

Misurata’s militias gained a reputation as some of the country’s toughest fighters during the 2011 uprising. But the powerful militias have been deeply embroiled in a fight against forces aligned with Gen. Khalifa Hifter, the Libyan army chief who declared war on the country’s Islamists in 2014.

The Misurata commanders have been cautious about taking on the Islamic State, even though the militias clashed with extremist fighters in Sirte. But the recent suicide bombing has prompted the commanders to shift their focus.

“They see the threat, and they are really focused on it now,” said Frederic Wehrey, a Libya expert at the Carnegie Endowment for International Peace.

Misurata’s militia leaders held meetings in Tripoli, the capital, this past week to coordinate a counterattack, according to an official from the city’s military council. Misurata sits along the coast between Tripoli and Sirte.

“The priorities have shifted,” Wehrey said. “Misurata is getting hit [by the Islamic State], and they are just down the road.”

Since the fall of Gaddafi in 2011, this city of about 500,000 — Libya’s third-largest — has enjoyed relative stability. Thanks to advanced infrastructure and the city’s port, Misurata has again established itself as a Mediterranean trade hub.

Advancing in Libya

Gaddafi cracked down on domestic Islamist groups during his four-decade rule. But Islamists became powerful after the 2011 rebellion, with some joining the government and others openly running armed factions.

Still, the Islamic State did not appear in Libya until mid-2014. A group of Libyan militants who had pledged allegiance to the Islamic State while fighting in Syria returned home and began to organize in the eastern city of Derna, according to experts and Libyan Islamists.

At the time, Libya’s weak government was fracturing into two entities: an Islamist-led administration in Tripoli, and a Hifter-aligned authority in the eastern city of Tobruk.

Later in 2014, the Islamic State leadership sent a delegation from Syria to Libya to formally receive pledges of allegiance to its self-declared caliph, Abu Bakr al-Baghdadi. The Libyan group set up three caliphate “provinces” in the east, in Tripoli and in the south. Each province has an Islamic State governor, but there is no single spiritual or military leader inside Libya, experts say.

For the Islamic State, Libya is attractive because of its location along the Mediterranean Sea, making it a potential launchpad for attacks on places such as Egypt and Tunisia, analysts say. The country’s vast desert regions and general lawlessness also mean the Islamic State could operate quite freely.

In February, Islamic State fighters drove a convoy of vehicles mounted with heavy weapons into Sirte, capturing a cluster of government buildings and a local radio station.

Soon the militants began enforcing their own brand of strict Islamic law. According to local news reports, militants established checkpoints to inspect vehicles and confiscate items such as CDs and cigarettes, which they say are not Islamic.

“These extremist forces were not so strong a few months ago,” said Mohamed Lagha, a Libyan journalist who has reported from Sirte. But “they have continued to grow” and now control most of the city, he said.

The Libyan Islamic State militants caused an international outcry in February when they released a video showing the beheading of 21 Egyptian Christians who had been abducted in December and January. In April, the group released a similar video in which militants beheaded 15 Ethiopian Christians and shot 15 more in Libya.

The Islamic State also has claimed terrorist attacks in cities such as Tripoli and Benghazi.

Despite the extremists’ advances, there are several factors that will probably hinder their growth, Wehrey said. The country’s 6.2 million people are mostly Sunni, so there are not the kind of sectarian divisions that have allowed the Islamic State to grow in Syria and Iraq.

Lacking in revenue

The Libyan affiliate also lacks a stream of revenue, hampering its ability to offer social services. In Syria and Iraq, the Islamic State has far more income because of its control of some of the countries’ oil production, as well as its ability to impose taxes and collect ransoms from kidnappings. Libya’s petroleum resources remain under the control of the two governments.

Still, the Misuratan military official said the Islamic State militants in Sirte are capable fighters.

“We are not sure how many [fighters] there are, and they are pretty well-armed,” the official said, speaking on the condition of anonymity because he was not authorized to comment to the media. “Of course they are a threat.”

Wehrey said the number of militants in Sirte is probably in the low- to mid-hundreds.

The military official said the Misurata factions plan to move against the Islamic State in Sirte before the end of the month, but they might not have enough manpower to attack so soon. The Misuratan brigades, which are made up of as many as 40,000 fighters, are deployed across Libya in their fight against Hifter’s forces.

The United Nations has for months worked to hammer out a peace deal between the two Libyan governments, which have been unable to cooperate in confronting the militants.

“We need the people upstairs to get their act together and agree that these extremists must be fought,” said Ismael Shighmani, a Misurata police officer who was close to the checkpoint that was attacked recently. “They are the main threat in Libya now.”

Read more:

In Libya, will Misrata be the kingmaker?

Why the Islamic State has its eyes on Libya

Oil-rich Libya, torn by conflict, may be going broke

Cunningham reported from Cairo.