BERLIN — Germans are reeling from a spate of violent attacks that have shaken a country already anxious about its open-door refugee policy and fearful that Islamist terrorist attacks like those in neighboring France could take place here, too.
Authorities said Monday that a 27-year-old Syrian man pledged allegiance to the Islamic State before he detonated a bag of explosives outside a music festival in the Bavarian town of Ansbach, killing himself and injuring 15 people on Sunday.
Earlier Sunday, a 21-year-old Syrian man killed a pregnant woman with a machete in Reutlingen near Stuttgart in what authorities said was likely a personal attack not related to terrorism.
The carnage followed a Friday night shooting rampage in a Munich shopping mall that killed nine — the act of a lone, disaffected German-Iranian teenager with no connection to Islam.
In a single week, a total of four attacks in Germany — three by recent immigrants and two claimed by the Islamic State — has shaken a citizenry anxious about recurring massacres in France and has resurrected concerns about the country’s ability to deal with the more than 1 million immigrants allowed into the country last year amid unrest in the Middle East.
Bavarian Interior Minister Joachim Herrmann said he had no doubt that Sunday’s attack in Ansbach was carried out by an Islamist terrorist.
“We found a video on the attacker’s cellphone in which he threatened an attack in the name of Allah and declared his allegiance to Abu Bakr al-Baghdadi, a leading member of IS,” Mr. Herrmann said at a press conference in Bavaria. “He also warned of an attack against Germans for standing in the way of Islam and as retaliation for the deaths of Muslims.”
The Ansbach attacker, who was identified only as Mohammad D in accordance with German privacy laws, was a rejected asylum seeker in Germany who was due to be deported to Bulgaria, where he already had been granted asylum, authorities said. He had been living in Germany since 2014 and was receiving psychiatric care after two suicide attempts.
In claiming responsibility for the bombing, the Islamic State said the attack was carried out by one of its “soldiers.”
The Islamic State-linked Aamaq news agency said the attacker acted in response to the extremist group’s call to target countries of the U.S.-led coalition fighting in Iraq and Syria, The Associated Press reported. Germany is not involved in combat operations but has contributed reconnaissance aircraft to the effort.
After the Islamic State connection surfaced, federal prosecutors in Karlsruhe, who investigate all suspected terrorism, took over the case. They said they would try to “determine if thus-far unknown accomplices or backers were involved in the crime.”
Last week, a 17-year-old Afghan refugee was shot dead by police after he injured five passengers with an ax on a train near Wurzburg, Bavaria. Police classified this attack as an act of terrorism after a hand-painted Islamic State flag was found among the refugee’s belongings.
German officials called on the public to remain calm and refrain from stigmatizing the hundreds of thousands of refugees who have streamed across the country’s borders in the past year.
Federal Interior Minister Thomas de Maiziere said Monday that Germany’s justice system is strong and that security would be tightened in public spaces via increased police presence.
“We will do all we can to prevent attacks like these in the future, but there are no guarantees,” Mr. de Maiziere said, adding that many Germans have asked him how they might have to change their daily lives now that this latest generation of terrorism has come to Germany. “We shouldn’t change our routines. But we also shouldn’t be careless. We need to carry on and have faith in our strength.”
Others used the crisis to point out shortcomings of the government’s security policies.
“It is virtually impossible to stop lone wolves if his social circle does not alert the authorities to alarm,” Rainer Wendt, chairman of the German Police Union, told broadcasters N24. “The police cannot watch all people. We have enough to keep up with from people who are said to pose a threat.”
Mr. Wendt said Germany had “lost control” of its own borders over the past year thanks to German Chancellor Angela Merkel’s open-door policy to Middle Eastern migrants bound for Central Europe.
“We gave up control over our borders last year and didn’t allow the police to check everything that should have been checked. Neither the identities of all of the people who have come here nor their mental and physical health have been examined,” he said. “Even though we see these days that psychological instability, terrorism and criminality are mixed up together.”
Mr. Wendt called for a stricter approach to better identify new arrivals and determine whether they pose any dangers to Germany.
Mr. de Maiziere defended the government’s policy.
“I disagree that we are too optimistic about refugees,” he said. “These are cases that came to Germany before the fall. The majority of these refugees are coming to us because they are unsafe.”
But Mr. de Maiziere acknowledged that not everyone was welcome. “Some of them don’t have a right to be here,” he said.
• This article is based in part on wire service reports.