TUNIS The attacks against Libya's biggest oil terminals were lethal and sustained. The last two weeks have seen suicide bombings, huge fires at storage tanks, and a hole blown in a major pipeline.
The oil ports of Es Sider and Ras Lanuf had been closed for more than a year, and the Islamic State militants advancing on them backed off after three days of shelling and clashes.
But the escalation of violence in Libya's coastal "oil crescent" has underscored the threat to an energy industry that, despite the political chaos plaguing the country, still provides vital income to the state.
Oil is central to Libya's livelihood and the power struggles following the 2011 overthrow of Muammar Gaddafi often focused on the industry. The OPEC member's exports plunged from 2013 as armed groups began shutting down production to press political demands.
Last year, as two rival governments competed for power from Tripoli and the east, Islamic State gained a foothold in the city of Sirte and launched its first attacks against oil infrastructure.
The group has not taken control of oil fields, as it has in Syria. But it has pushed along the coast from Sirte, consolidating its presence in towns including Ben Jawad, just 30 km (19 miles) west of Es Sider.
"I think the danger is very grave, especially in Es Sider," Mohamed al-Harari, a spokesman for the National Oil Corp (NOC) in Tripoli, told Reuters by telephone. "The area seems to be secure, but nobody can guarantee anything."
The recent spate of attacks began on Jan. 4 with a double car bombing at a Petroleum Facilities Guards outpost near Es Sider. As the violence intensified, the NOC posted a "cry for help" on its website.
And as a precaution against further attacks, the company said on Thursday that it had sent a tanker to remove oil from the terminals, though guards, citing security concerns, had not granted it access.
The guards are a military sub-division created in 2005 and paid by the NOC. Their numbers swelled to at least 12,000 after the uprising, but analysts say their allegiances are uncertain and their fighting capacity limited.
At least 18 guards were killed in the recent clashes, and spokesman Ali al-Hassi told Reuters the force expected another Islamic State attack "at the earliest opportunity".
With militants threatening to puncture defenses at Es Sider and Ras Lanuf, "there is a very real risk" of an attack on the still-functioning Brega terminal another 115 km (70 miles) to the east, said Richard Mallinson, an analyst at research consultancy Energy Aspects.
They could also potentially strike the oil fields of Sarir, Messla and Nafoura, which account for about 60 percent of Libya's current oil output of just under 400,000 barrels per day, he said.
Libya produced 1.6 million barrels per day before the uprising.
DESTROYING, NOT HOLDING
So far, Islamic State has aimed to destroy infrastructure to damage state revenue streams and undermine a U.N.-backed Government of National Accord (GNA) scheduled to take power in the coming weeks, said Claudia Gazzini, senior Libya analyst at the International Crisis Group.
Islamic State's Libyan forces, estimated to number in the low thousands, might not be able to seize control of oil facilities from the guards, she said.
But control may not be a priority. Libya's oil industry is largely structured on exports of crude oil across the Mediterranean, so it is hard to make significant profits locally.
"They're aiming to create a deficit of the public funds and create social and economic upheaval," said Gazzini.
Es Sider and Ras Lanuf -- with an export capacity of 600,000 barrels per day -- were processing about 300,000 bpd before they were shut in December 2014 amid fighting that had already damaged some of the terminals' 32 storage tanks.
Two more tanks were hit, and the fires spread to a further five during this month's clashes. NOC spokesman Harari said the company had not yet been able to assess the damage accurately, but he estimated that up to 850,000 barrels had been destroyed.
Backers of the unity government hope the threat from Islamic State, which also claimed a suicide attack this month that killed at least 60 in the western town of Zliten, will push Libya's myriad factions to unite against a common enemy.
"The fight against Daesh (Islamic State) and the fear of Daesh expansion, this is one of the consensus topics," said UN Libya envoy Martin Kobler. "I see a growing tendency to rally behind the political agreement."
But the agreement for the GNA still faces fierce opposition from some factions, and it is unclear how and when the government will move to Tripoli.
"It's a mountain to climb for the GNA to establish legitimacy, even before we start talking about organizing security against Islamic State," said Mallinson.
(Additional reporting by Ayman al-Warfalli in Benghazi; editing by Patrick Markey and Katharine Houreld)