LAST weekend’s shootings in Copenhagen seemed to imitate those that took place in Paris a month earlier, which also targeted cartoonists who had made fun of the Prophet Muhammad. Yet Denmark has been grappling with such questions for longer. The long-running “Danish cartoons” debate began in 2005 when the newspaper Jyllands-Posten published satirical drawings of Muhammad, leading to protests around the world. To outsiders, it may seem surprising that such a row began in Denmark, which many picture as a free-thinking oasis devoted to generous social-welfare schemes and religious, ethnic, sexual and countercultural tolerance. Yet Denmark experienced a particularly sharp and early version of Europe’s debate over multiculturalism and Islam. For years, even liberal Danish politicians have been calling multiculturalism a “failure”. Why?

Denmark’s lefty image, if it was ever accurate, is at least 15 years out of date. In the late 1990s the Danish People’s Party (DPP), founded by Pia Kjaersgaard, began to denounce immigration, multiculturalism and Islam as alien to Danish society and values. The party tapped into fears of rising crime and fed on the resentment of working-class and conservative Danes who felt ignored by the liberal governing elite. From 2001 until 2011 the DPP’s support was needed by minority centre-right coalition governments run by the liberals and conservatives. In exchange, the DPP gained partial control of Denmark’s immigration policy, which quickly became among the most restrictive in Europe.

Denmark prides itself on an exceptionally open and frank political culture. The new right-wing politicians were willing to be very frank indeed. Ms Kjaersgaard accused Danish Muslims of living at a “lower stage of civilisation, with their own primitive and cruel customs”. The party has lost influence since a centre-left government was elected in 2011, but its restrictive immigration and asylum policies have become accepted across the political spectrum. The generosity of the country’s social-security net has made people quicker to accuse immigrants of exploiting it. Meanwhile, a highly cohesive and demanding civic culture, which was the basis of Denmark’s liberal social-welfare policies, has alienated anyone who finds it hard to conform. This has made the country fertile ground for Islamist recruitment. Over 100 Danish jihadists have gone to Syria and Iraq, one of the highest rates per person in Europe.

It would be a mistake to see Denmark’s 50-year-long encounter with immigrants from Muslim countries as a failure, or to treat Danish Muslims as a coherent, problematic group. They hail from Morocco, Somalia, Turkey and Denmark itself; most are simply Danes whose religion is Islam, as Danish as anyone else. For a minority, poor integration policies and a reluctance to conform to local norms have led to isolation, while modern Islamism has provided a new identity to claim and a violent way to assert it. Mainstream society has reacted to that violence by reasserting its own norms and values, widening the gulf. A similar process is playing out in almost every country in western Europe. If Denmark’s story is different from those of the Netherlands, Britain, France, Belgium and the rest, it is mainly because Denmark seems to have been a few years ahead of the curve.