JUST 25 miles and a spectacular bridge separate Copenhagen from Malmo, Sweden’s third-largest city. Denmark and Sweden share bonds of history, language and culture. Each has a fondness for open labour markets, high taxes and a generous welfare state. But on immigration policy, the two countries are worlds apart.

Take this year’s migration crisis. Denmark’s centre-right government, propped up by the anti-immigration Danish People’s Party (DPP) since an election in June, has taken the bared-teeth approach to asylum. In September it placed advertisements in four Lebanese newspapers warning would-be migrants of the hardships they would face if they came. It grudgingly offered to take in 1,000 refugees from other European countries, then changed its mind. Sweden, by contrast, has opened its arms. This year some 150,000 Syrians, Afghans and others have sought asylum in this country of 10m people (most of them travelling via Denmark). Proportionally, that is more than Germany.

All that changed on November 24th, when Stefan Lofven’s Social Democratic government buckled under the pressure of numbers. Asa Romson, the deputy prime minister, was close to tears as she announced measures designed to stem the refugee flow into Sweden. From April 2016 most refugees will enjoy only temporary protection, and their right to bring family members to Sweden will be curtailed. For a country that has long seen itself as the conscience of Europe, that was quite a reversal.

As a result there is more than a whiff of Schadenfreude in the Danish corridors of power. Since 2001, under the influence of the DPP, successive governments have tightened asylum and citizenship policy. (A rule barring foreign spouses younger than 24 from moving to Denmark is one of the world’s toughest.) Sweden’s new measures are old hat in Denmark, which passed its latest round of restrictions in July and is considering more, including a proposal to strip asylum-seekers of valuables to pay for their care. “People have been looking to Sweden and laughing,” says a Danish official. “[The Swedes] were naive.”

Danes would do well to restrain their mirth. Despite the obvious need, EU countries have preferred games of beggar-thy-neighbour over a co-ordinated migration policy. Just as border closures in Hungary caused havoc for Croatia and Slovenia, Sweden’s unilateral changes will rebound on Denmark. Danish asylum claims, already at record levels (some 20,000 are expected this year), are climbing further, months before the Swedish measures take effect.

That will further strain the countries’ relations. Sweden has urged Denmark to follow its lead and implement border checks, but Lars Lokke Rasmussen, Denmark’s prime minister, refuses, saying that could trap more asylum-seekers inside Denmark. In September the two governments failed to mesh their responses after refugees surged into Denmark seeking to reach Sweden. Lykke Friis, a former Danish minister, says relations have not been this bad for years.

Fears over asylum coloured a referendum held on December 3rd, as The Economist went to press. The ballot paper presented Danes with a baffling choice: should their government convert its “opt-out” on the EU’s justice and home affairs matters to a Britain-style “opt-in” (meaning it could choose which policies to adopt)? Inevitably this arcane question was crowded out by whether a “yes” vote would allow Brussels to dump asylum-seekers on Denmark. The government vowed it would not. But as elsewhere in Europe, Danes have lost faith in politicians’ promises.

Many Danes think political correctness has smothered the migrant debate in Sweden—unlike Denmark, where no opinion is off-limits. This, they charge, has allowed the far-right Sweden Democrats, an anti-immigrant outfit with roots in neo-Nazism, to rise to the top of Swedish opinion polls as the only alternative to the soggy pro-immigration consensus.

There is something to this. Yet Denmark’s hard line on asylum has not defanged the populists either. Over the years the DPP (which began as an offshoot of an anti-tax insurrection) has dragged moderate parties in its direction: even the Social Democrats are immigration hardliners these days. But dancing to the tune of the DPP has not blunted its appeal. The party came second in June’s election, with 21% of the vote. The Sweden Democrats, whom other Swedish parties shun, poll only a little higher.

My policy is better than your policy

Each country struggles with integration. Some Swedish cities are stratified by ethnicity; racist mobs have firebombed refugee centres. The 31 areas on the Danish government’s “ghetto list” hardly resemble Detroit, but nor are they trouble-free. In February a Palestinian-Danish gunman killed two people in Copenhagen, one at a free-speech event and another outside a synagogue. It is getting harder to counter the siren calls of Islamist groups. Although local authorities, including Copenhagen’s, try hard to integrate minorities, they sometimes seem to be tugging in a different direction from their national masters.

The prosperous lands of Scandinavia seem a long way from the seas that carry migrants to Europe’s shores, or the tense borderlands of the Balkans through which they trek. Yet Sweden and Denmark have still managed to replicate some of the problems of Europe’s more troubled areas. Like many other European countries they have jealously guarded their right to act alone in the teeth of a continental crisis—hang the consequences for others.

Their respective differences on the benefits of immigration, or obligations to refugees, used to be little more than a Nordic curiosity. Today, with thousands of migrants looking to one country or the other, they are part of the problem. It is disputes like these that explain why Europe has struggled to get on top of its migration crisis. That they afflict two of the EU’s most successful countries shows how hard they will be to resolve.