“GET free or die trying,” runs a graffito in English on the wall of a migrants’ detention centre on the outskirts of Tripoli, Libya’s capital. The author was one of the countless migrants to pass through the fetid, overcrowded facility, his fate unknown.

Some of the people herded into more than 20 such centres across Libya were intercepted by Libyan naval vessels as they attempted the perilous journey across the Mediterranean. Others were arrested before reaching the sea by Libyan militias that have held sway since the revolution that toppled Muammar Qaddafi in 2011.

Thanks to its oil wealth, Libya has long been a magnet for migrants from farther south. Under Qaddafi, they numbered between 1.5m and 2.5m in a country whose indigenous population was around 6m. Nobody nowadays has reliable figures. Fewer people from sub-Saharan Africa are looking for work in Libya, because it is so chaotic. But the borders have become even more porous. Libya is now almost certainly the busiest transit route for black Africans heading illegally to Europe.

Migrants pay more than €1,000 ($1,370) each to get onto rickety boats to Malta and the Italian island of Lampedusa. Many do not survive. Earlier this month the Italian authorities recovered 14 bodies and rescued around 200 people after a boat sank between Libya and Sicily. In the past few years, thousands have drowned.

Qaddafi exploited European anxieties over illegal migration, once declaring himself the only bulwark against a “black Europe”. Just before the uprising against him, he asked the European Union for €5 billion ($7 billion) a year to tackle the problem.

Libyans fret that it has worsened since the revolution. Officials in Tripoli claim that the number of migrants waiting in Libya to get to Europe runs to hundreds of thousands, including Syrians and south Asians as well as sub-Saharan Africans. Nearly 27,000 have landed in Italy so far this year, ten times the number recorded in the same period a year ago. Those who stay in Libya exist in a twilight world of cramped safe-houses, living hand-to-mouth, always in fear of arrest. Hundreds of them look for jobs on Tripoli’s streets.

Huddled and hapless in Malta Libyan officials say they cannot solve the problem alone. They often bring up the subject with European diplomats. Echoing Qaddafi, Libya’s interim interior minister recently threatened to “facilitate” the passage of migrants to Europe if the EU failed to help stop them. Migrants from sub-Saharan Africa spread disease and get involved in crime, he said. “Libya has paid the price. Now it’s Europe’s turn to pay.” The problem is by no means limited to Libya. Few governments across the northern half of Africa find it easy to police their borders. By some estimates, more than 600,000 illegal migrants are waiting on the southern Mediterranean shore, hoping to embark for a better life. A report by the Global Initiative Against Transnational Organised Crime, a Geneva-based lobby, documents the routes taken by this vast wave of migrants, as well as their origins and means of transport. It also describes the role played by traffickers, terrorists and corrupt officials, casting light on the murky politics of the Sahara and the Sahel, the belt of arid scrub along its southern fringe. The report’s authors argue that European governments should tackle the problem in Africa, rather than after the migrants have ended up in miserably overcrowded asylum centres in Europe. Take the example of Agadez, a smuggling entrepot in northern Niger. According to the report, at least half of all west African migrants who reach Lampedusa first pass through this warren of adobe houses. The ethnic Toubou who dominate the trade charge migrants between $200 and $300 for passage into southern Libya, or ask them to carry drugs in lieu of payment.

Smuggling is the town’s main business. When 92 people died near Agadez last September after their vehicles broke down in the Sahara, Niger’s authorities promised to stamp out large-scale people-smuggling. But with revenues of perhaps $1m a week at stake, officials inevitably connive. Even when raids do take place, the smugglers simply switch routes and tactics.

“Dismantling the networks of intermediaries, drivers, guides, migrant ‘welcome centres’ and clandestine migration consultants would place the regional economy of Agadez under significant stress,” says a diplomat in Niger. The towns of Gao in Mali and Tamanrasset in southern Algeria share a similar profile: traffickers, tribal chiefs, corrupt officials, jobless desperadoes and jihadists all rub along to claim a slice of the profits. These networks create a living for many thousands of people.

There are few alternatives. Desertification and swelling populations outstrip agricultural productivity in much of the arid Sahel. A recent resurgence of conflict in the Central African Republic, Mali, northern Nigeria, Somalia and South Sudan has continued to displace millions, pushing ever more young men north towards Europe. This month’s mayhem in northern Mali threatens to tip the country back into civil war; camps in Mauritania and Burkina Faso still overflow with refugees from a previous round of fighting. It is not surprising that the Mediterranean beckons.