When the Libyan arm of the Islamic State first raised the group's black flag over the coastal city of Sirte almost one year ago, it was just a bunch of local militants trying to look tough.
Today Sirte is an actively managed colony of the central Islamic State, crowded with foreign fighters from around the region, according to residents, local militia leaders and hostages recently released from the city's main prison.
"The entire Islamic State government there is from abroad - they are the ones who are calling the shots," said Nuri al-Mangoush, the head of a trucking company based here in Misrata, about 65 miles west of the Islamic State's territory around Sirte. Many of its employees live in Sirte, and five were jailed there recently.
As the Islamic State has come under growing military and economic pressure in Syria and Iraq, its leaders have looked outward.
One manifestation of the shift is a turn toward large-scale terrorist attacks against distant targets, including the massacre in Paris and the bombing of a Russian charter jet over Egypt, Western intelligence officials say. But the group's leaders are also devoting new resources and attention to far-flung affiliate groups that pledged their loyalty from places like Egypt, Afghanistan, Nigeria and elsewhere. There are at least eight in all, according to Western officials.
Of those, by far the most important is based in Sirte, a Libyan port city on the Mediterranean about 400 miles southeast of Sicily. Western officials familiar with intelligence reports say it is the only affiliate now operating under the direct control of the central Islamic State's leaders. In Libya, residents of Sirte and local militia leaders say the transformation of the Islamic State group here has been evident for months.
"Libya is the affiliate that we're most worried about," Patrick Prior, the Defense Intelligence Agency's top counterterrorism analyst, said at a recent security conference in Washington. "It's the hub from which they project across all of North Africa."
The leadership of the Islamic State, also known as ISIS or ISIL, is now clenching its grip on Sirte so tightly that Western intelligence agencies say they fear the core group may be preparing to fall back to Libya as an alternative base if necessary, a haven where its jihadis could continue to fight even if it was ousted from its original territories.
"Contingency planning," said a senior Defense Department official, speaking on the condition of anonymity to discuss intelligence. Western officials involved in Libya policy say that the United States and Britain have each sent commandos to conduct surveillance and gather intelligence on the ground. Washington has stepped up airstrikes against Islamic State leaders. But military strategists are exasperated by the lack of near-term options to contain the group here.
Libya could present the West with obstacles at least as intractable as those in the Islamic State's current home base in Syria, Raqqa, amid the bedlam of the civil war. There, the Islamic State is hemmed in by a host of armed groups with international backing and is being hammered by U.S., Russian, French and Syrian airstrikes.
In Libya, where a NATO bombing campaign helped overthrow Col. Moammar Gadhafi four years ago, there is no functional government. Warring factions are far more focused on fighting one another than on taking on the Islamic State, and Libya's neighbors are all too weak or unstable to lead or even host a military intervention.
The Islamic State has already established exclusive control of more than 150 miles of Mediterranean coastline near Sirte, from the town of Abugrein in the west to Nawfaliya in the east. The militias from the nearby city of Misrata that once vowed to expel the group completely have all retreated. Only a few checkpoints manned by one or two militiamen guard the edge of the Islamic State's turf, where its fighters come and go as they please.
Militia leaders and Western officials estimate that the group's forces in Libya now include as many as 2,000 fighters, with a few hundred in Sirte and many clustered to the east, around Nawfaliya. A flurry of recent bombings, assassinations and other attacks has raised fears that the city of Ajdabiya, farther to the east, is the group's next target. Its conquest could give the Islamic State control of a strategic crossroads, vital oil terminals and oil fields south of the city.
What is more, in the tangle of factions that have taken over whatever remains of the Libyan government, Islamic State fighters have been receiving weapons and other support from the accumulated oil wealth that should belong to the Libyan state. And they are getting the weapons through an intermediary who himself played a peripheral role in the deadly attack on the U.S. diplomatic compound in Benghazi in 2012.
One of the Islamic State's most senior leaders, a former Iraqi army officer under Saddam Hussein now known as Abu Ali al-Anbari, recently arrived by boat from across the Mediterranean, residents and Western officials say. And Western officials say another senior Iraqi leader of the Islamic State - Wissam Najm Abd Zayd al Zubaydi, also known as Abu Nabil - may have recently served as the group's top commander in Libya until he was killed this month in a U.S. airstrike near the eastern Syrian city of Darnah.
"A great exodus of the Islamic State leadership in Syria and Iraq is now establishing itself in Libya," said Omar Adam, 34, the commander of a prominent militia based in Misrata.
The group in Sirte has also begun imposing the parent organization's harsh version of Islamic law on the city, enforcing veils for all women, banning music and cigarettes, and closing shops during prayers, residents and recent visitors said. The group carried out at least four crucifixions in August.
Last month the group held its first two public beheadings, killing two men accused of sorcery, according to prison inmates who knew the men and a Sirte resident who said he had witnessed the killings.
An image to sustain
The Islamic State once called on Muslims everywhere to come to Syria and Iraq to join its self-declared caliphate. Its propaganda portrayed migration as all but a religious duty. Muslim doctors, engineers and other professionals as well as fighters should all hurry to join the Islamic State, the group's English-language magazine Dabiq often warned, or they would face the consequences on Judgment Day.
"Rush to the shade of the Islamic State with your parents, your siblings, your spouses and children," the first issue of the magazine declared last year.
But the messages began to change as the state-building project came under increased military pressure in Syria. Increasingly, Islamic State leaders began to focus more of their attention on the battle abroad. When the United States started airstrikes against the group last fall, its official spokesman, known as Abu Mohammed al-Adnani, called for Muslims in the West to stay where they were and murder those around them.
"If you can kill a disbelieving American or European - especially the spiteful and filthy French - or an Australian, or a Canadian," Adnani urged in an audio message, "then rely upon Allah and kill him in any manner or way however it may be."
A few such "lone wolves" answered the call, including a gunman who attacked the Canadian Parliament and killed a soldier nearby.
The logic of the Islamic State's growth, though, has always depended on a steady beat of battlefield victories. It craved the headlines to reinforce its apocalyptic propaganda and lure new recruits. It depended on conquests to loot money and weapons. In Syria and Iraq, all of that has recently slowed to a near standstill.
The Islamic State has seized no significant territory there since May, when its fighters took the cities of Ramadi in Iraq and Palmyra in Syria. Instead, it withdrew in June from the Syrian border town of Tal Abyad and this month from the towns of Sinjar in Iraq and Al Hol in Syria.
The Islamic State forces "still send small groups to attack us now and then, but they can't move in big convoys or they'll get bombed by the coalition," said Faisal Abu Leila, a rebel commander allied with Kurdish forces in northern Syria.
Recent U.S. airstrikes on Islamic State-controlled oil trucks and facilities have sent fuel prices soaring. Until lately, the Syrian and Iraqi governments paid thousands of civil servants working in Islamic State territories. But this summer the Iraqi government stopped paying salaries in Mosul and Anbar province, and shifts on the battlefield have prevented public employees in Islamic State territory from reaching banks on the outside to cash their paychecks.
"ISIS is still strong," said the manager of an electronics store who lives in Raqqa. "But it has lost popularity among ordinary, uneducated people because it has lost its brilliant victories."
Perhaps hoping to sustain its image of invincibility, the Islamic State's propaganda has increasingly promoted the operations of its foreign affiliates. Western intelligence agencies say it is devoting more resources to them as well.
Most remain largely autonomous. The Egyptian branch of the Islamic State, deemed second after Libya's in the scale of its threat, had a long record as a domestic insurgency before pledging its allegiance. The branch appears to have acted on its own initiative to carry out the bombing of the Russian charter jet on Oct. 31, say Western officials familiar with the intelligence reports. But the objective, those officials say, was to impress the group's central leadership in order to win financial support. The core Islamic State immediately embraced the bombing, which killed 224 people, trumpeting the achievement of its Egyptian "brothers."
The Nigerian group Boko Haram has been around for two decades and became a regional scourge five years ago. Western officials say its pledge of allegiance to the Islamic State this year changed almost nothing. The group had been almost comically inept in its use of social media, though, and it has evidently learned from the Islamic State's savvy example.
Western officials believed that a breakaway faction of the Taliban in Afghanistan was also using the Islamic State name primarily to distinguish itself. But then in recent months the core group delivered several hundred thousand dollars to the Afghan fighters, helping them gain ground and recruits. Western officials say its operations so far have mainly sought to attract publicity or stir sectarianism, but clashes with the Taliban are increasing.
Foreigners in Control
Two fuel truck drivers recently released after a month in Sirte's main prison said they were stunned by the extent of the foreign control over the group's Libyan outpost. Both spoke on the condition of anonymity for their safety but provided consistent accounts in separate interviews, backed up by a third interview with their employer, Mangoush, who had also debriefed three other drivers kidnapped with them.
The drivers were stopped on Oct. 6 on a desert highway 90 miles south of Misrata, in part for the fuel in their trailers and in part to be taken as hostages. They were surprised to find themselves surrounded by two dozen masked fighters who spoke mainly in foreign dialects of Arabic - there were many Tunisians, but also Egyptians, Iraqis, Yemenis and Sudanese, they said.
The fighters and guards in Sirte all bowed to a Saudi administrator, or "wali," who had been sent by the Islamic State to preside over the city. (A former Sirte City Council member now in exile in Misrata said the Islamic State periodically rotates in new administrators, who typically are from the Persian Gulf.) Whenever drones were heard flying overhead, guards would run to the Saudi, take away his cellphone, and hurry him away to safety, the truck drivers said, suggesting that the Islamic State considered him important enough to be a target of U.S. airstrikes.
The truck drivers said that the Islamic State fighters were commanded by Iraqis more powerful than the Saudi, but they met only the civilian administrator. He questioned each of the roughly 90 prisoners himself and offered some clemency in exchange for "repentance" - that is, a pledge of loyalty to the Islamic State.
"He would ask each prisoner, 'Why are you here? What is your case?' He has a very good memory," one driver said. But, he added, "Thieves would join them just to get out."
The prisoners were put in front of a flat-screen television to watch a video of the Islamic State's leader, al-Baghdadi, proclaiming himself caliph in a sermon in Mosul last year, with occasional pauses while the guards explained the importance of a given passage. At other times, the prisoners had to watch hours of footage of the group's attacks around the world, in Libyan cities like Benghazi, but also in Syria, Iraq and Egypt. "They would bring in a hard drive with what they called 'the new releases,'" one prisoner said.
Both recounted meeting an Islamic State fighter from Chad who had been jailed for disobeying orders. But they also met a young man from Benghazi who worked with the guards and said he had just returned after five months of fighting in Syria for the Islamic State. He gave his name as Abu Malik and he planned to return to the battlefield after a short visit with his mother, suggesting that the Islamic State could arrange easy transit back and forth.
The drivers said the Islamic State seemed to command a strong intelligence network in Misrata. They marveled at an interrogator's probing and well-informed questions about their families and personal histories. "If he said he was my own brother I would have believed him," one driver said.
Other prisoners often returned from questioning with bloody faces, lash marks on their backs, or other marks of abuse. Then, one Friday last month, they said, two older prisoners who had been accused of sorcery - Adel Hafez, in his 50s, and, Saed Al Ma'dani, a septuagenarian - were led away to be executed in the first public beheadings in the central square under the Islamic State's rule.
"The guards were so excited and happy," one driver recalled. "They said, 'Thank God, we have started the hudood,'" or Islamic punishments.
"They are vicious," the other driver said. "Nobody is safe from them, and Sirte is going to be very different."
The drivers themselves were treated well. They were informed at the start that they had been taken as hostages for a prisoner exchange. On Nov. 11, five kidnapped truck drivers and the bodies of three Misratan fighters were swapped for the release of 11 Islamic State men held by the authorities in Misrata, according to the drivers and Mangoush, their boss.
The Islamic State also appeared to be seeking toll revenue from the main desert highway, Mangoush said. "People who are working with us and living in Sirte told us, 'ISIS is willing to give you safe passage in exchange for bringing fuel and other things into Sirte,'" he said.
Instead, he said, the Misrata trucks stopped using the road, cutting off hundreds of trucks a month that had previously carried goods and supplies south through the desert.
"If we agree to a deal, what we would get is small peanuts compared to what ISIS would gain," he said. "The next step, they will be here in Misrata."
Sirte was the hometown and last refuge of Gadhafi, and the Islamic State's roots there go back to the battle to remove him.
A Misratan brigade under the leadership of a charismatic local extremist entered at the time and stayed to occupy part of the city.
By the fall of last year, Sirte was at the center of an escalating civil war. The militias that had overrun Libya were squaring off in two rival coalitions battling for money and power.
One faction based in Misrata included various moderate and extremist Islamists. The other, based in eastern Libya, was dominated by a would-be strongman, Gen. Khalifa Hifter. The Misrata forces took over the government in Tripoli, and a second government aligned with Hifter set up in the eastern city of Tobruk (that one includes the internationally recognized parliament).
The fighting between the two sides allowed the extremists to take full control of Sirte but also killed off their leader, leaving militants searching for a new direction just as the Islamic State was storming across Iraq and declaring its caliphate.
"There was a vacuum," said Makluf Ramadan Salim, 45, the Sirte City Council member now in Misrata. "That was when Sirte first heard the name of the Islamic State."
"That is when the foreign fighters started appearing - the Tunisians, the Egyptians," he added. By the beginning of 2015, he said, foreigners were openly manning checkpoints and questioning drivers.
In February, the Islamic State fighters in Sirte collaborated with the core group in Raqqa on the beheading of about 20 Egyptian Christian migrant workers who had been kidnapped in Sirte. The Raqqa group's media arm released under its own logo a video of the killings that had been produced with its usual studio-quality sophistication but was filmed on the Libyan coast.
A brigade from Misrata set out for Sirte in March vowing to retake the city. But it never got past the outskirts. Its commanders said at the time that they had been surprised by the Islamic State's strength and numbers. The brigade's fighters complained they had not been paid in months.
"The Islamic State had weapons, they had strength and we had no support whatsoever," one of the brigade's fighters recalled last week. He gave his name only as Ali, for the safety of cousins still living in Sirte.
Some unconvincingly dismissed the group as Gadhafi "remnants."
"Martyrdom operations, bombings and foreign fighters," Hassan el-Karami, a Libyan Islamic State preacher mocked in a sermon. "After you see all of this, you still say 'remnants?' Who do you think you are fooling?"
In August, Islamic State fighters killed a popular ultraconservative imam, Khalid bin Rajab Ferjani, for refusing to swear allegiance. When his followers and his tribe tried to rise up, the group killed three dozen of them, crucifying at least four in a busy traffic circle.
The group seized the houses and property of those who fled, and the leaders gave them to their fighters, including the foreigners, as "spoils of war," said Salim, the council member, who soon escaped himself.
"They established Islamic police, an Islamic court, and a tax office, and they numbered all the shops in Sirte to collect taxes," he added ruefully. "They showed they really were a state."
The Islamic State's fighters are attacking both of the country's rival governments with bombings and assassinations, but the Central Bank continues to pay for public budgets and payrolls across both governments and the Islamic State's territory. Sirte residents - including Islamic State fighters - drive into Misrata to cash checks and buy fuel and other supplies.
Through a web of contradictory local alliances, the jihadis have even been able to tap into a line of weapons and funding through the Misrata-dominated government in Tripoli and its allies among the Benghazi militias - even as it continues to attack that faction in Tripoli, Misrata and elsewhere.
The point man responsible for obtaining the money from the Tripoli government and buying weapons for the Benghazi militias - including the Islamic State fighters - is Wissam bin Hamid, a commander well known for his ties to hard-line Islamist groups.
He was the leader of Benghazi's most formidable fighting force at the time of the deadly assault on the U.S. diplomatic compound in Benghazi in 2012. By his own account he stood outside watching and did nothing to stop it, and he later tried to cover up for the fighter that witnesses said led the attack, Ahmed Abu Khattala.
Among the Islamist militias fighting Hifter in Benghazi, though, bin Hamid "is the person everyone revolved around," in part because he has maintained good relations with all of the factions, including the Islamic State, said Ziad Bellam, another brigade leader in the same coalition. "His only ideology is defeating Hifter."
Outraged at the realization that their own faction was indirectly supporting the Islamic State fighters attacking it, several Misrata militia leaders complained to the Tripoli government. "The Islamic State in Sirte will fight us with the same weapons you are funding," Adam, the militia leader, said he told the officials in Tripoli.
When Tripoli refused to change its policy, Adam and other Misratan militia leaders confronted bin Hamid, their supposed ally, with the same accusation, demanding that he at least declare publicly that he opposed the Islamic State.
Bin Hamid refused, said Adam, Bellam and others close to bin Hamid. He insisted that he privately opposed the Islamic State but "he does not want to split the front against Hifter," Bellam said.
Unconvinced, Adam and others Misrata leaders say they have barred bin Hamid from returning to Misrata.
But others here connected to the Tripoli government say they are stilling working with bin Hamid even if he is providing weapons to the Islamic State.
"Wissam bin Hamid is a true revolutionary, and he is working with the government," said Ismael al-Shokri, who holds the title of head of military intelligence for the Misrata-Tripoli forces.
Shokri promised that those forces would someday turn their guns against the Islamic State. But he declined to say when.