BERLIN — For months, many Germans have worried that the exodus of refugees into their country would upend their comfortable existence, straining state coffers and public services. Now, they worry something even more dear is at stake: their safety.

In the wake of the New Year’s Eve attacks on hundreds of women by foreigners in Cologne and other cities, Angela Merkel’s greatest challenge has shifted from convincing Germans they can shoulder the burden of more than 1 million newcomers to reassuring her citizens she can keep them safe.

That won’t be easy. Since the attacks, hundreds of women, many of whom say they were assaulted on the square in front of the main train station, have come forward to file criminal charges. By Sunday, police had registered more than 500 complaints, 150 alleging sexual molestation.

Most of the attackers were described as being of “Northern African” or Arab descent. Authorities have said some of the suspects were refugees but the details remain unclear. Justice Minister Heiko Maas said over the weekend that authorities believed that the New Year’s Eve attacks may have been coordinated over social media in advance.

Germany’s national media, initially slow to report on the attacks, is now full of breathless first-hand reports of the night’s events and soul-searching over whether it’s acceptable to discuss criminality among refugees.

The cover of the weekly Der Spiegel, which hit newsstands on Saturday, carried a fuzzy picture of the chaos on the square under the headline: "Germany on the Brink."

“Simultaneously, the fears of both pro- and anti-foreigners were realized,” the magazine concluded.

Focus, another glossy weekly, ran a cover picture of a naked white woman with black handprints on her body, an image some said was as misogynistic as it was racist.

In one television interview, a woman who said she was assaulted at the train station even displayed the underwear ripped from under her dress.

Less than 40 percent of Germans now believe the police can ensure their safety, according to a poll conducted after the attacks for the Sunday edition of the newspaper Bild. About half of those polled worry that an attack like the one in Cologne could occur in their own area.

“The events in Cologne have left many Germans deeply shaken because it became clear that night that the state hasn’t just reached its limits but is internally weak and indecisive,” said Berthold Kohler, a publisher of the daily Frankfurter Allgemeine Zeitung and a prominent conservative voice.

German law and disorder

While security is important to the public in every country, maintaining strict public order in Germany, in big ways and small, borders on obsession.

Pedestrians famously obey red lights at crosswalks, even if no cars are approaching. Households devote assiduous attention to separating trash into a panoply of recycling bins. Public transportation operates on the honor system. Street demonstrations are coordinated with authorities down to the last detail.

In short, Germans expect stability and order in every facet of life.

That yearning, like much else in contemporary German life, is rooted in the country’s tumultuous modern history. For decades, Merkel’s Christian Democrats, which have run the country for most of the postwar period, have been regarded as the guarantors of that sense of security.

Personified by leaders like Wolfgang Schäuble, a former interior minister and the current finance minister, the party stands for law and order.

While the public has yet to panic, tension is building, both on the street and online. Police in Cologne clashed with anti-Islam protestors on Saturday, breaking up their march with water cannons after it turned violent.

Online forums, meanwhile, have exploded in vitriol since the attacks. What has shocked many observers is that radical comments previously found on extremist websites are making into more mainstream platforms.

The operator of a popular Cologne-based Facebook forum called Nett-Werk Köln, meant for users to share local tips, decided to suspend the group after a rash of extremist comments. The site had almost turned into “a warzone of verbal violence,” Phil Daub, the man behind the site, complained.

Attacks changed 'everything'

At a meeting of the CDU’s executive board in Mainz over the weekend, Merkel and other party leaders were told the mood among the party base over the refugee crisis had hit a new low. The attacks changed “everything,” said Volker Bouffier, CDU chief in the state of Hesse.

The party leadership responded with a pledge to get tough, including by making it easier to revoke residency rights of criminal foreigners and to deport rejected asylum applicants.

The public “expects us to follow through with our political will and what we want as a country of laws,” Merkel said at a press conference in Mainz.

That’s easier said than done. German courts have made it clear the government cannot deport foreigners to countries where they could face torture or the death penalty. Given that virtually all of the recent refugees hail from such countries, the likelihood that Germany will deport any foreign convicts is slim.

At this rate, another 1.5 million refugees will arrive in Germany by end of 2016.

“With this initiative, the CDU is trying to mask both its own failure to deal with these challenges and the internal dispute within the party over the future refugee strategy,” said Roger Lewentz, a regional leader of the Social Democrats.

Merkel’s refusal to place a limit on the number of the refugees entering the country is becoming increasingly difficult to sell to her party. Her strategy of relying on the European Union and Turkey to help stem the flow has yet to bear fruit.

If anything, the events in Cologne, together with the recent terrorist attacks in France, have made it even less likely other EU countries will take in large numbers of refugees.

Turkey, which agreed in November to take steps to prevent Syrian refugees from leaving the country, has yet to follow through, despite an EU pledge for at least €3 billion in aid.

Over the weekend, Merkel again urged her party colleagues to give her more time. But with the CDU’s Bavarian sister party pressuring her to limit the number of refugees allowed to come in 2016 and public confidence waning, her position has become increasingly tenuous.

Further violence involving refugees, in particular a terrorist attack, would make her strategy untenable.

So far this year, German authorities have registered 3,000 to 4,000 new refugees per day, a rate that if sustained would see another 1.5 million refugees arrive by the end of 2016. On Sunday, the country’s minister for international development raised alarms by warning that only about 10 percent of the refugees who had left Syria and Iraq had arrived in the EU.

“Eight to 10 million are still on their way,” the minister, Gerd Müller, told Bild.

This article was updated to correct spelling of Berthold Kohler.