ROME – An outbreak of fierce fighting in Libya between militias has revealed how Europe’s best efforts to stop hundreds of thousands of migrants sailing from Libya to Europe can unravel in the lawless country.

Recent clashes in Sabratha, a coastal town west of Tripoli, claimed 40 lives as rival militias — which all profess loyalty to Libya’s UN-backed government — fired rockets at each other in the town center, damaging hospitals and schools.

One likely reason behind the battle was resentment over money, following widespread reports that one of the militias had been paid millions of euros by Italy to stop its lucrative business of loading African migrants into dinghies and sending them to Italy — which lies north across the Mediterranean.

“It was like throwing breadcrumbs to fish in a fountain — whatever the Italians did was a reason for the escalation,” said Mattia Toaldo, a senior analyst at the European Council on Foreign Relations.

“The militias were fighting for control of Sabratha, because that control is crucial to getting something from the Italians,” he added.

Some 108,000 migrants, many from sub-Saharan Africa, have sailed from Libya this year, after 181,000 made the journey last year, earning a fortune for brutal traffickers who bring the migrants up through the Sahara desert and lock them in detention camps while they wait for a boat. The business has flourished since the demise of Libyan strongman Col. Muammar Ghedaffi in 2011, which left the country rudderless and contested by two rival governments, one in the capital Tripoli which has UN-backing, and a rival in Tobruk, which is allied with a military leader Gen. Khalifa Haftar.

The flow of migrants has helped spur a rise of anti-migrant sentiment in Europe and aided the rise of populist parties. Finding a solution has been hampered by conflicting foreign political intervention, with Russia, France, Egypt and the UAE backing Gen. Haftar against Tripoli’s UN-backed leader Fayez al-Serraj, who is supported by Italy.

In Sabratha, a main departure point for migrants, a steady traffic of migrants was reportedly organized by Ahmed Dabbashi, head of the Anas Dabbashi brigade, who is nicknamed “The Uncle.” Business flourished until July, when observers were puzzled by a sudden drop in the number of migrants being rescued at sea. In August the number then dropped again, by 82 percent year on year. One explanation given was the increase in activity by the Libyan coast guard, which was intercepting more migrants and returning them to Libya after receiving EU-funding training and new vessels.

However, in late August, reports emerged that Dabbashi had met with Italian officials and received a payment to stop trafficking and devote his energies to preventing over traffickers from working.

Italy already had a channel of communication with Dabbashi because his militia was employed to provide security at the nearby Mellitah oil facility, which is co-run by the Libyan government and Italian energy company ENI. Italian interior minister Marco Minniti denied any payments had been made, while Dabbashi said he had struck his deal with the UN-backed government in Tripoli, which had promised him a government salary, vehicles and a clean record, effectively turning his militia into a government security force.

That however meant there were two government forces in Sabratha. The other, known as the Operations Room, was set up last year by Tripoli to tackle any ISIS forces in the city. Last month, fighting erupted between the two forces. The Operations Room group said they wanted to push all militias out of Sabratha. Dabbashi claimed he was being targeted by forces allied with the Operations room who wanted to carry on trafficking migrants.

“The Operations Room has old, Ghedaffi-era army soldiers in its ranks and is allied with rivals of the Dabbashis as well as a Salafist militia,” said Toaldo. “The fighting was the fiercest fighting seen since 2011 — not the usual theater you often see in Libya.”

Last week, after three weeks of fighting, the Operations Room drove Dabbashi out of town and even announced it had taken over the job of providing security at Mellitah.

This week, thousands of migrants trapped in camps, allegedly held there by Dabbashi after he stopped trafficking, were discovered and freed, and the UN now estimates there are 10,000 migrants in the town and surrounding area.

The issue facing Europe now is whether trafficking will resume. After a quiet September, 1,374 migrants were picked up at sea by European rescue vessels between Oct. 9 and 11, suggesting sailings may be starting up again.

“We have yet to see what the new bosses of Sabratha will do about trafficking, and my assumption is that Dabbashi will attempt a comeback,” said Toaldo.