Geveva // A popular uprising in the Libyan port of Derna over the weekend has achieved the previously unthinkable – the expulsion of ISIL brigades who had been holding the town.

Protests and fighting triggered by the public execution of a popular local postman spiralled into an uprising that has seen a rare reverse for the extremist group that had been gaining ground across Libya.

Derna’s celebrations may be short-lived because the militia spearheading the fighting, and now claiming control of the town, is an Al Qaeda affiliate, the Abu Salim Martyrs Brigade.

But for the moment Derna is locked in euphoria with one image above all flooding social media - crowds of citizens dumping ISIL’s black flag from buildings and flyovers and replacing it with the Libyan tricolor.

Protests against ISIL’s public executions in the 12 months since it established its rule in Derna began on Friday and demonstrators came under fire from its units in the town centre.

Later that day, the Abu Salim Martyrs Brigade, named after 1,200 prisoners massacred by former dictator Muammar Qaddafi in a Tripoli prison of the same name in 1996, led attacks on the ISIL-held police headquarters.

As fighting intensified on Saturday, three ISIL suicide bombers blew themselves up in a desperate attempt to fight back, with battles raging from street to street.

Government airstrikes then hit ISIL positions, and fighting that day saw 25 people reported killed. It was unclear how many of these were ISIL fighters.

On Sunday, Abu Salim Martyrs leaders proclaimed the town was under their control. ISIL, their bases overrun, fled for the forested hills of the Green Mountains.

Meanwhile, forces from the internationally recognised government, which is based in Tobruk, are pushing towards the town from the east, attacking an ISIL base at Ras Al Hilal, 45 kilometres from Derna.

Local militiamen and police have now captured more than 150 ISIL fighters, made up of Libyans and foreigners, parading them in trucks around the town centre.

It marks a dramatic reversal of fortune for ISIL, whose growth in Libya had until then seemed unstoppable.

Derna, a town of 150,000 on Libya’s eastern coast, has long been a centre of Islamic learning, but it has also produced powerful militant groups.

In the 1990s they formed the backbone of the Libyan Islamic Fighting Group in a failed uprising against Qaddafi. Crushed, the group’s members fled, some to Afghanistan and Iraq.

In 2006, US forces in Iraq captured a list of names and home towns of Al Qaeda foreign fighters. The list showed that no town of its size in the world contributed more of those fighters than Derna.

After the 2011 revolution that ousted Qaddafi, extremist brigades tussled for influence in the town, with Abu Salim Martyrs fighting occasional battles with rival brigade Ansar Al Sharia, blamed by Washington for the killing of US ambassador Christopher Stevens in Benghazi in 2011.

Last summer, both Abu Salim Martyrs and Ansar Al Sharia were brushed aside by the arrival of ISIL, which brought 300 battle-hardened fighters from its Al Battar Brigade which fought in Syria. Many Ansar Al Sharia fighters defected to ISIL.

ISIL installed a Yemeni preacher, Abu Nabil Al Anbari, to supervise executions. His whereabouts since the fighting are not known.

ISIL established dominance in the town, and began holding public executions in the city sports stadium.

From Derna, ISIL spread down the coast to Sirte and in November they claimed responsibility for car bombings at the already abandoned UAE and Egyptian embassies in Tripoli.

In January, ISIL killed nine people in a suicide attack on a Tripoli hotel, followed by the gruesome execution of 21 Christian foreign workers, 20 from Egypt, dressed in orange jump suits near Sirte.

The extremists fanned out from Sirte to capture oil fields in the Sirte basin in March, kidnapping nine foreign oil workers. Seven of them are still missing after two Bangladeshis were released.

With its capture this month of Sirte’s air base, ISIL seemed poised to open oil-smuggling routes to Libya’s unguarded southern border.

However, they have failed to win over Libyans.

There was popular outrage over a February triple-suicide car bombing that killed 35 civilians at Qubba, south of Derna, and further anger when ISIL crucified eight members of a Derna family in April.

To date, ISIL has taken advantage of Libya’s civil war, with the forces of the country’s two rival governments preoccupied with fighting each other.

Diplomats hope that a UN peace plan, unveiled earlier this month, may bring the warring governments together.

“They need to form a common front against ISIL,” said one western diplomat.

Perhaps just as important in combating ISIL, from the evidence of events in Derna, may be people power.

foreign.desk@thenational.ae