“WHAT the hell is wrong with this country?” fumed Beatrix von Storch to her 30,000 Twitter followers on December 31st: “Why is the official police page in NRW [North Rhine-Westphalia] tweeting in Arabic?” The MP for the hard-right Alternative for Germany (AfD) party detected in the force’s multilingual new-year greeting a bid “to appease the barbaric, Muslim, rapist hordes of men”. The next day her tweet—and, for 12 hours, her entire account—vanished from Twitter. In the subsequent political storm Alice Weidel, co-leader of the AfD, came to Ms von Storch’s defence: “Our authorities are subordinating themselves to imported, rampaging, groping, punching, stabbing migrant mobs,” she tweeted. That, too, was promptly deleted.

Germany’s memories of the Gestapo and the Stasi undergird its commitment to free speech. “There shall be no censorship,” decrees the constitution. Even marches by Pegida, an Islamophobic and anti-immigrant movement founded in 2014, receive police protection. But the country of Kristallnacht and the Holocaust also takes a punitive attitude to what it deems “hate speech”. Inciting hatred can carry a prison sentence of up to five years, Hitler’s “Mein Kampf” is available only in annotated form, and it is illegal to single out any part of the population for insult or other abuse that could “breach the peace”. Irmela Mensah-Schramm, a Berlin pensioner who spray-paints over swastikas and other racist graffiti, is a national hero.

Reconciling these two convictions—for free speech and against hate speech—is becoming harder, particularly since Angela Merkel’s refugee gambit in 2015. Opening Germany’s borders to some 1.2m mostly Muslim migrants has fuelled the rise of nativist outfits like the AfD and Pegida. Racist propaganda and sensationalist reports (some, though not all, fake) of criminal and rapist immigrants have rippled across social media. In 2016, for example, the number of criminal investigations into online hate speech in Berlin rose by 50%. A number of the newcomers from the Middle East and Africa are anti-Semitic. Confronting such ills without encroaching too much on freedom of expression is tricky.

The most prominent example of the balancing act is the new Net Enforcement Law (NetzDG), of which Ms von Storch’s and Ms Weidel’s tweets were early victims. Inspired by the rise of fake news and a report suggesting that only a minority of illegal posts on social media were being removed within a day (and just 1% or so on Twitter), the law cleared the Bundestag last June and came into force on January 1st. It sets out 20 things defining a comment as “clearly illegal”, such as incitement to hatred or showing the swastika. Once posts are flagged by users, a social-media firm has 24 hours—extended to a week in complex cases—to check and remove those that contravene the rules, or face a €50m ($60m) fine. In the first week, Facebook’s over 1,000 German moderators have had to process hundreds of thousands of cases.

Overwhelmed by the volume and wary of incurring such huge fines, social-media firms are erring on the side of censorship. On January 2nd Titanic, a satirical magazine, joked that Ms von Storch would be its new guest tweeter. Two of the subsequent tweets mocking the AfD politician were censored. When Titanic republished them, its account was suspended for two days. The epitome of NetzDG’s overreach came last weekend when an old tweet by Heiko Maas, the justice minister who had introduced the law, calling an author who opposes immigration an “idiot” was removed, seemingly under its provisions.

Too much anti-hate?

Criticism is mounting. The AfD has been joined by the liberal Free Democrats, the Greens and the socialist Left party in calling for its repeal. The Federal Association of German Newspaper Publishers is also opposed. Its director warns that social-media firms are defaulting to deletion in cases of doubt, to control costs. The government says it will review the law’s effects in several months’ time.

Predictably, one man’s protest is another’s hate speech. On December 8th Israeli flags were burned at the Brandenburg Gate in Berlin in response to Donald Trump’s recognition of Jerusalem as the country’s capital. Despite accompanying chants of “Israel, murderer of children”, the local police said the act was covered by freedom of speech legislation and was thus protected—prompting the Israeli ambassador to urge that the law be changed and Armin Schuster, an influential Christian Democrat MP, to argue that immigrants found guilty of burning the Israeli flag should be expelled from Germany. His idea may come into practice: the CDU is planning to change deportation rules in time for Holocaust Memorial Day on January 27th, to make it easier to remove anti-Semitic newcomers.

Mrs Merkel’s refugee policies have also fuelled free-speech debates by making her government reliant on Recep Tayyip Erdogan, Turkey’s president, whose co-operation has helped reduce the flow of migrants through the Balkans. Last April the chancellor declined to block the prosecution of Jan Böhmermann, a German comedian who had made crude jokes about Mr Erdogan, under an archaic law against insulting foreign heads of state (which has since been repealed).

All of which points to a broader truth: regulating speech was easier in the past, when Germany was a more settled, homogeneous and conformist place. The wave of new arrivals since 2015 has accelerated its long-term evolution into a more plural, fragmented country. Long after Britain and France, Germany is becoming a land of immigrants. The arrival of the AfD in the Bundestag after its election in September increased the number of groupings there to a record six, up from three for most of the post-war period. The internet is generating dissenting and outspoken competitors to the country’s more cautious established media. This new, more open and varied Germany is harder to govern.