BERLIN —Donald Trump may be testing the boundaries of tolerance on the U.S. campaign trail. But here in Germany, the government is effectively enforcing civility, taking aim at a surge of hate speech against refugees and Muslims.

As Western Europe’s most populous nation grapples with a historic wave of mostly-Muslim migrants, politicians and activists are decrying a rash of incendiary speech bubbling to the surface of German society. In a country whose Nazi past led to some of the strictest laws in the West protecting minorities from people inciting hatred, prosecutors are launching investigations into inflammatory comments as judges dole out fines, even probation time, to the worst offenders.

German authorities, meanwhile, have reached a deal with Facebook, Google and Twitter to get tougher on offensive content, with the outlets agreeing to apply domestic laws, rather than their own corporate policies, to reviews of posts.

Critics call it the enforcement of political correctness, raising the question of what constitutes hate speech and sparking a national debate over free expression. Germans have been outraged, for instance, by reports of more than 100 sexual assaults and robberies in the city of Cologne allegedly committed by gangs of young Arab and North African men on New Year’s Eve. Some Germans are questioning whether their online comments could be taken down, or whether they could be charged with incitement, for publicly pondering whether refugees could have been among the assailants.

The Syrian conflict has created the largest wave of refugees to hit Europe since World War II.

Two of the suspects have been identified as Moroccan citizens. But Cologne police say they have not yet determined whether any of the assailants were recently arrived asylum seekers. Nevertheless, the incidents have fed a strain of anger and suspicion here beyond the traditional migrant critics in the right wing.

“It’s not politically correct to say anything against migrants. We don’t have freedom of opinion anymore. #Cologne,” Tweeted a German user from Hanover going by the handle Pulvermann.

Proponents are hailing the government effort as a way to foment respect while also controlling the most savage voices in society.

“After the Second World War, it was clear that anything that could re-create National Socialist or racist thinking had to be stopped,” said Volker Beck, a lawmaker from Germany’s Green Party. Last month, he filed a lawsuit against a German anti-refugee group after its followers issued death threats against him for publicly defending the right of Muslim women to wear veils at school.

“I’m a civil rights defender, but there has to be a red line,” Beck said.

The German campaign, perhaps not surprisingly, is meeting stiff resistance from far-right groups, including the extremist National Democratic Party of Germany, which in March will face a hearing to determine whether it should be banned. Yet even leaders on the political left are questioning whether the bid to weed out hate is going too far.

Protesters marched through the central train station in Cologne, Germany, to call for an end to violence against women after dozens of attacks shook the city on New Year's Eve. (Facebook/Rote Antifa [Essen])

Stefan Körner, chairman of Germany’s liberal Pirate Party, argued that democracies “must be able to bear” a measure of xenophobia. He condemned the government’s deal with social media outlets to get tougher on offensive speech, saying that “surely it will lead to too many rather than too few comments being blocked. This is creeping censorship, and we definitely don’t want that.”

It remains unclear how aggressive social media sites are being — some highly offensive posts in German have indeed been quickly removed from Facebook in recent days while others have lingered online for days. Yet the push here happens as a country with a built-in sensitivity to provocative speech has seen a decidedly fiercer public discourse as more than 1 million asylum seekers and migrants crossed Germany’s border last year.

The offensive views include an online post of a hangman’s noose as one solution to the refugee crisis, a quip by a right-wing politician about the breeding habits of Africans, as well as a comment made by a controversial speaker at an anti-migrant rally lamenting the closure of World War II-era concentration camps.

The surge of incendiary comments online has been so strong that one of Germany’s largest media outlets, Der Spiegel, disabled its readers’ comment function for articles related to refugees.

Such rhetoric — considered harsher than anything seen here in years — is alarming many Germans, including Chancellor Angela Merkel. In her New Year speech, Merkel, who has adopted one of the most open policies in Europe toward asylum seekers fleeing war in the Middle East, warned against the forces of hate once again brewing in Germany.

Her countrymen, she said, should not listen to “those with coldness, or even hate in their hearts, and who claim the right to be called German for themselves alone and seek to marginalize others.”

Harsh comments are earning some Germans more than scorn. In the town of Wismar in northeastern Germany, for instance, a judge in October sentenced a 26-year-old man to five months probation and a 300 euro fine after the man had posted on his Facebook page that refugees should “burn alive” or “drown” in the Mediterranean.

In September, the home of a 26-year-old Berlin man was raided by police, who confiscated his computer and phones after he had posted the tragic image of the dead 3-year-old Syrian boy whose body on a Turkish beach became a symbol of the refugee crisis. Along with the photo, he had posted: “We are not mourning, we are celebrating!”

A 29-year-old Berlin woman, meanwhile, received five months probation in July after she had posted comments on Facebook about an alleged rape of a German woman by an asylum seeker. “Filth out!” she wrote, arguing that if tougher measures against refugees were not deployed, “more asylum seekers’ homes will burn.”

Indeed, proponents of more controls on hate speech here say there is a direct correlation to the vitriol now flying in the German public domain and the sharp spike of attacks on refugee centers. Last year, German police reported 906 attacks against asylum seeker homes, ranging from arson to physical assaults. The figure amounts to more than a fourfold increase, compared with 2014 numbers.

In Germany, a person can face incitement charges for comments aimed at creating hostile feelings or triggering violence against a particular race, religion or ethnicity. To publicly endorse, play down or justify the crimes of the Nazi regime can be punished with up to five years in prison.

Last September, German authorities worried by the increase in hate speech against refugees contacted major social media outlets, forming a new task force including the government, companies, industry associations and activists to tackle the problem. On Dec. 15, the task force announced an agreement for tougher monitoring.

Facebook officials now say they are reviewing posts more stringently and using legal opinions and language experts to determine whether users’ comments are infringing on German law. Sometimes, they say, it means parsing whether posts containing common insults are framed in a way that could be potentially illegal as opposed to genuine political expression.

“We’ve looked at our general rules and understand that very specific forms of language may constitute hate speech,” said Richard Allan, Facebook’s vice president of public policy in Europe. “Our German reviews are reviewing the meanings of German words and trying to understand what language crosses the line.”