LAST week a Danish surveillance aircraft spotted a rickety fishing boat stuffed with would-be migrants 24 nautical miles off the Libyan coast. It alerted the Italian coast guard in Rome, which in turn dispatched Poseidon, a Swedish multipurpose vessel on patrol in the Mediterranean. Three hours later the ship’s crew ran into 613 men, women and children, from places as far apart as Nigeria and Bangladesh. One by one they clambered aboard, where they were given food, water and a quick health check before awaiting their delivery to shore. Like trophies, pictures of the vessels the Poseidon has intercepted adorn a stairwell below the ship’s mess hall. Since its deployment to Sicily on June 1st as part of an expansion of Operation Triton, the European Union’s border-surveillance mission in Italy, Poseidon has taken part in 14 rescue operations and saved 2,600 souls.

If only Europe’s governments could co-operate as happily. This week marked their latest failed attempt to reach a piddling goal: the relocation of 40,000 asylum-seekers from Italy and Greece, which are groaning under record arrivals, across most of the EU’s other members. Despite Stakhanovite efforts from Luxembourg, which as the holder of the EU’s rotating presidency was charged with securing national contributions to reach the number, the pledges reached just 32,256. Five times as many migrants reached Italy and Greece in the first half of this year alone. Explaining their opposition, sceptical governments speak airily about tackling the “root causes” of migration instead. As these include civil war in Syria, tyranny in Eritrea and a Libyan state that has lapsed into gangsterism, this is code for doing nothing.

Faced with such small-mindedness one can despair. For a continent that aspires to be a force for good Europe has been a dismal failure at dealing with migrants from outside its borders. Thousands have drowned in the Mediterranean. Legal channels for skilled migrants are uneven and often ineffective. Even the sole European success this week—a deal to resettle 22,504 refugees from outside Europe—loses its sheen when set against the size of the problem: there are an estimated 4m displaced Syrians alone, most languishing in Turkey, Jordan and Lebanon.

Yet Charlemagne finds reasons to hope. This week’s numbers are puny but they are more than the zero the EU had previously been able to agree on. Triton’s expansion, which relies on support from 27 European countries, will be hard to reverse, for Europeans no longer seem prepared to see the Mediterranean turn into a graveyard. Officials are thinking seriously about other parts of the problem, from Europe’s fractured asylum system to a permanent relocation mechanism, to be triggered when migrant arrivals spike. Most European governments now seem to accept that migration is a problem for all of them, not just the littoral states—even if they disagree on the solutions. A year ago, says an Italian official, we could not have dreamed of a permanent relocation scheme. Now we are at least talking about it.

What explains the change? The death of around 800 migrants off the Libyan coast in April helped shame politicians into action. But previous disasters have prompted little more than wrung hands and empty promises; it is the sheer scale of the movements that has woken Europe up. Over 160,000 unauthorised migrants have reached the EU this year. Human-rights groups talk of the worst refugee crisis since the second world war. Such numbers make it hard for even the most dedicated isolationists to pull up the drawbridge and lock themselves inside Fortress Europe.

It might seem odd to detect cause for cheer. After all, at last month’s summit of EU leaders the relocation proposal sparked arguments fiercer than anything over Greece’s euro membership. Some countries are reverting to atavistic impulses; witness Hungary’s construction of a fence along its border with Serbia. But migration is a charged topic, and Europe’s governments have competing interests. America, a unified state with vast federal assets, has struggled to get a grip on its illegal-immigration problem. It was always going to be harder in Europe. But if a common migration policy is to emerge, it would inevitably begin like this.

From Basra to Bratislava

Still, several tripwires lie ahead. One is the unprecedented experiment of the relocation scheme. Its fiercest foes, largely in eastern Europe, must start planning now for the Eritreans, Iraqis and Syrians who will arrive from October. Few have much experience in integrating foreigners. Moreover, asylum-seekers are often not agnostic about their place of refuge. Migrants who end up in, say, Slovakia, may rush to join compatriots or kin in Sweden, even if they forfeit social benefits under rules which may be dreamed up to discourage such moves. If large numbers of migrants up sticks as soon as they are relocated, the Italian dream of a permanent relocation scheme will die.

A second potential pitfall is the struggle of many European countries to send failed asylum-seekers home. Improving the rate of return is tricky, says Liz Collett of the Migration Policy Institute, a think-tank. Governments that do it well, such as Britain’s, invest in complex, granular relationships with migrants’ home countries. The formulaic “readmission agreements” on which the EU relies are much less effective. Yet to win support for the new asylum-seekers they will soon receive, European governments, particularly those under siege from populist right-wingers, must show voters that they are dealing with the old, failed ones.

Perhaps the hardest fact to swallow is that no policy, however well-crafted, can hope to keep pace with the epic forces that drive people from their homelands. A refugee surge from Ukraine, for example, could overturn Europe’s strategy. And new policies bring their own challenges: resettling refugees is humane, but it may establish communities that go on to attract new illicit migrants. Such are the dilemmas thrown up by today’s era of mass migration, and Europe must adapt. Happily, it has started to.