BIN JAWAD/AL-SIDR, Libya—The first artillery rounds landed just as the setting sun threw shadows on this barren stretch of coast. Atop an earthen observation berm, a young fighter in an oversize flak vest peered through a makeshift periscope. Six miles away was the prize: white storage tanks filled with oil.

Over the walkie-talkie came a hurried voice: “Saadun, Saadun, the bird is here, the bird is here!” Saadun was the codename for a portly commander in the Libya Dawn militia and my escort on the frontline when I visited Libya in January. His men—boys, actually—had teased him earlier for struggling to haul his hefty frame up the berm.

The bird was a MiG-21 or MiG-23 fighter-bomber belonging to the rival Dignity forces. An overhead roar gave way to crackling flashes across a cloudless sky—flak from anti-aircraft guns. The MiG dropped its bomb about a mile away. It was the second and final airstrike of the day. Like the other, it did no damage.

* * *

This is the battle for Libya’s two largest oil ports at the towns of al-Sidr and Ras Lanuf. It is but one front of a complex and largely forgotten civil war that, since May of last year, has devastated the country. The fighting has opened deep fissures that regional powers and transnational jihadists like al-Qaeda and the Islamic State are exploiting. Over 2,500 people have been killed since last summer. In the grim accounting of the wars in Syria and Iraq, this may seem a paltry figure by comparison. But Libya’s population is three and a half times smaller than Syria’s, and more than five times smaller than Iraq’s. And the war’s persistence is affecting not just Libyans but the security of surrounding African and, increasingly, European nations. “We should have no illusion on the fact that we can stay away from Libya. Libya will not stay away from us,” Federica Mogherini, the European Union’s foreign-policy chief, said recently.

On one side of the fight are the forces of Operation Dignity gathered around General Khalifa Hifter. Hifter is a former Qaddafi-era officer who defected in the 1980s and returned to the country in 2011. In May, he launched Dignity as a military campaign to root out Islamist militias in the eastern city of Benghazi and exclude Islamists from political power. His allies include disaffected military units, security men from the old regime, prominent eastern tribes, federalists demanding greater autonomy for the east, and militias from Zintan and other western towns.  

On the opposing side is the Libya Dawn coalition, born in July as a countermovement to Dignity. It includes ex-jihadists from the Libyan Islamic Fighting Group, militias from the powerful port of Misrata, and fighters drawn from certain Tripoli neighborhoods, the ethnic Berber population, and some communities in the western mountains and coast. Dawn has forged a tactical alliance with a coalition of Benghazi-based Islamist militias that are battling Hifter’s forces, one of which is the U.S.-designated terrorist group Ansar al-Sharia.  

Each side claims its own parliament, prime minister, and army. But the United Nations, the United States, and other world powers only recognize the Dignity-allied government, with its parliament in the eastern city of Tobruk and its cabinet in nearby Bayda. Nearly three and a half years after Libyan rebels and a NATO air campaign overthrew Muammar al-Qaddafi, the cohesive political entity known as Libya doesn’t exist. There is no central government, but rather two competing claims on legitimacy and sovereignty.

The rival factions have all but obliterated Libya’s conduits to the outside world. The nation’s major airports lie in smoking ruins. Merchant ships shun its ports. Most embassies (including America’s) and foreign businesses have ceased their operations in the country. In recent months, the fighting has centered on the nation’s central-bank reserves and oil facilities.

The federalist militias allied with Hifter’s forces currently control the oil-pipeline terminals at al-Sidr and Ras Lanuf. Their commander, Ibrahim Jathran, rose to notoriety in 2013 for seizing the ports to compel the Tripoli-based government to grant easterners more control over oil revenues. Jathran, who was ironically part of the guard force meant to protect those facilities, tried unsuccessfully last year to sell the oil on the black market. After the Dignity-Dawn split, Jathran aligned himself with Hifter and the Tobruk-based parliament.

On December 13, Libya Dawn forces, drawn mostly from Misratan militias, launched “Operation Sunrise” to wrest the terminals from Jathran and his Dignity backers. The fighting shut down the terminals’ operations, cutting Libya’s overall oil production to one-fifth of pre-2011 levels (output was at 325,000 barrels per day in January; last October it was at 900,000). On December 25, a rocket struck a storage tank, igniting an inferno that blotted the sky with thick black smoke and caused the loss of about 1.8 million barrels of oil. The blaze was subdued only after nine days of Herculean firefighting.

As a result of OPEC’s decision not to cut oil supplies, the world market’s reaction to the drop in production has been largely muted—oil prices recently rose 4 percent, in part because of the fighting. But the consequences for Libya’s recovery are serious given the mounting infrastructural damage. These oil facilities are, in effect, Libya’s patrimony, and that patrimony is being squandered by both sides.

Today, the fighting has slowed to a grinding, static form of war whose rhythm is set by howitzer rounds and Grad rockets. Hifter’s forces use aging Russian fighter-bombers during the day and Hind helicopters at night—remnants of Qaddafi's air force. Sometimes they send ships to shell the Misratans’ logistical base in the now-deserted town of Bin Jawad. Occasionally they hit the airport and seaport in Misrata itself. Most of their artillery strikes come in the early morning; the Misratans wait to respond until late afternoon, when the sun is at their back.

A suspected cluster munition (Frederic Wehrey)

In Bin Jawad, the Misratans showed me where Hifter’s planes had bombed a bank, a school, and a mechanical repair shop. At the bank, I saw what appeared to be unexploded cluster munitions, a weapon banned by many countries but not Libya. (Mark Hiznay of Human Rights Watch identified the munition as a Russian-origin PTAB-2.5M air-dropped bomblet, used by Qaddafi’s air force during the 2011 conflict but not observed since.) In the sloping hills outside the town, we visited the ruins of a cemetery where a bomb had churned up eight or nine corpses. The desecration offended my guides deeply; they mentioned it to me more frequently than attacks on the living.  “Hifter can’t even let the dead lie in peace,” said one fighter.

During lulls in the fighting, young gunners at anti-aircraft sites rest by their trucks in the shade. They play cards and smoke tobacco from water pipes. At night they gather in makeshift barracks in Bin Jawad, watch Braveheart on Tunisian television, and sometimes drink the Libyan moonshine known as bokha. They sleep four or five to a room and wake to a breakfast of mashed dates and olive oil.

When I arrived at the front, a ceasefire had just been declared to coincide with UN-brokered peace talks. But it collapsed within hours, with both sides blaming the other. The Misratans told me that an artillery strike had killed one of their fighters, a 19-year-old. Saadun radioed to his commander for permission to retaliate, and  received it immediately. At a staging area near Bin Jawad, fighters hoisted long Grad rockets into a pipe-organ launcher mounted on a truck, amid long, low-pitched chants of “God is Great.” About two hours later the barrage began, with pounding in the distance and lightning flashes across a darkening skyline.

* * *

The commander of Operation Sunrise is a trim, gray-bearded man name Salah Jabu.* Trained as a hydraulic engineer, he speaks fluent English with the measured precision of his trade. Under Qaddafi, he was jailed twice—“for expressing my opinions.” He worked in Misrata’s steel plant and overseas in Italy, Thailand, and China. “I never imagined myself as a military guy,” he told me.

Now he leads a roughly 3,000-strong, mostly-Misratan contingent of the “Third Force” that is garrisoned at Bin Jawad. Many Third Force soldiers wear patches that say Jaysh Libi (Libyan Army) on their camouflage fatigues, but their fighting vehicles—Toyota trucks with heavy-caliber guns in the back—bear the insignias of individual katibas or militia “battalions,” over 90 percent of which hail from Misrata. The notion of a Libyan army—on either side of the conflict—is largely a fiction. What exists instead is a loose constellation of armed groups. Many of the Misratan forces fighting for Libya’s oil are the same units that defended Misrata during its epic siege in 2011—a pivotal battle often described as Libya’s “Stalingrad,” which paved the way for the liberation of Tripoli and the fall of Qaddafi. Jabu himself said he led the city’s eastern defenses.

Today, these battalions have spread out across the western half of this vast country.  Third Force militias are fighting against Hifter’s tribal allies from Zintan and Warshafana for control of a strategic airbase. In the southern desert, they’ve deployed to the provincial capital of Sabha, which until recently was racked by ethnic fighting between Tabu, Tuareg, and Arabs. The Misratans maintain that they are keeping the peace. Their base at the foot of the city’s Ottoman fortress and their roving checkpoints, they say, have finally allowed shops to open and hospitals to function. But some locals criticize them as just another occupying force that plays favorites among the tribes, much as Qaddafi did.

Misratan Third Force militiamen load a Grad rocket (Frederic Wehrey)

In attacking al-Sidr, Jabu said the Third Force is acting under orders from an elected parliament, the Tripoli-based General National Congress, to liberate the country’s oil facilities from eastern separatists. Of course, his rivals don’t recognize this parliament or its order, and the United Nations has repeatedly condemned attacks on oil facilities, including one in early February that left 10 dead. The threat of economic sanctions on Sunrise’s commanders is real: U.S. officials told me they were “considering” such measures, and Jabu hinted that he had already received warnings from the United Nations.

But for Jabu and the Misratans, the stakes are much higher than oil. They are seeking to prevent the return of what they call “the deep state,” led by Hifter and backed by counterrevolutionary regimes in Egypt and the United Arab Emirates.

For their part, Dignity leaders see the fight as a struggle to safeguard Libya’s oil wealth from a rogue government dominated by radical Islamists and terrorists.  Dignity officials have claimed that forces from Ansar al-Sharia, the terrorist group, are fighting beside the Misratans on the frontlines east of Bin Jawad. Sunrise commanders have repeatedly denied the charge, and I found no evidence of the group on my visit to the front.  

“We haven’t even started yet,” Saadun, the young frontline commander, told me. In the shadows of an arms depot near Bin Jawad, he showed off the Paladin, a massive, self-propelled howitzer with a range of nearly 20 miles, captured from Qaddafi’s stockpiles during the war. He accused Jathran’s forces of placing artillery in front of storage tanks as a shield, and said the Paladin hadn’t been used yet for fear of striking the tanks and starting another fire. Even worse, Saadun added, was Jathran’s use of Chadian Toubou mercenaries. It was a litany of bluster, half-truths, and recriminations that is typical on both sides.

Meanwhile, Misrata is buckling under the war’s economic damage. During my week in the merchant city last month, business magnates told me of declining profits. Freight trucks, long a source of income for many Misratans, sat idle at the city’s gates; with the entire eastern half of Libya now off-limits, they don’t have many places to go.

If there is any hope out of the impasse, it is in UN-backed dialogue. The key question now is whether those representing Misrata—and indeed the rest of Libya’s factions—have enough clout to make a peace deal stick, given the highly atomized nature of militia authority. Jabu told me that he does not approve of the talks but would “follow orders” whatever their outcome. A hardline faction within Misrata remains committed to fighting. Increasingly, though, the rising threat from the Islamic State may be tipping the scales toward the moderates.

* * *

On a nighttime helicopter flight that I took across the desert from Sabha to Misrata, a hooded young man sat with his head down, sobbing faintly. He was a Third Force fighter en route to the funeral of his brother, also a Third Force member, who had been killed a day earlier by assailants claiming to be affiliated with the Islamic State.  

The details were murky. A northbound convoy of Third Force soldiers had apparently been stopped a month prior at a false checkpoint north of Sabha. Seven of the soldiers were kidnapped, and three were later found dead by the road. Those released said the kidnappers had declared that they were from the Islamic State. Some Misratans disputed this claim, instead blaming brigands and ex-regime loyalists from the al-Qaddafa tribe who oppose the Misratans’ presence in the south; others accused Dignity forces.

If the story is confirmed, it would not be the Misratans’ first run-in with the jihadist group. In the past weeks, Misratan fighters have clashed with alleged Islamic State militants in an area known as Jufrah and at the Mabrouk oil field south of Sirte.

“Our next fight will be with Ansar al-Sharia and the Islamic State,” Jabu the Libya Dawn commander, told me, a week before the Islamic State’s Tripoli branch staged an attack on the Corinthia Hotel in the capital that left nine dead, including one American security contractor.

Such admissions are important because the Misratans in Libya Dawn have long been accused of a dangerous ambivalence or duplicity on the jihadist threat in Libya. Several key figures I spoke with in the city admitted to providing arms and funding to the Benghazi-based Revolutionaries’ Shura Council, which includes Ansar al-Sharia. But they were adamant that they only supported legitimate “revolutionary” militias in the Council like the Libya Shield One and the Rafallah al-Sahati Companies, and not Ansar, an al-Qaeda-linked terrorist group. Many argued that jihadist militancy ran counter to the city’s business ethos and moderate brand of Islamic piety. They argued that the rising Islamic State threat should be addressed through the rule of law and a unified Libyan government. It is an argument that many U.S. officials are emphasizing in their interactions with both Dignity and Dawn forces.

Back in Bin Jawad, a fighter named Ali sat smoking outside the barracks in a deserted plaza on the morning of my departure. Two days before, I had hitched a ride to the frontline with his convoy, which was ferrying howitzer shells. Now he seemed tired. He had two kids back in Misrata and a father in Jordan undergoing heart surgery. “It’s been four years since the Revolution and we are still fighting,” he observed. “I want to go home.”

* This post originally identified Libya Dawn commander Salah Jabu as Salah Bayu. We regret the error.