A 17-year-old Afghan asylum seeker is suspected of carrying out an ax attack on a German commuter train. The Islamic State has claimed that the young man was a “fighter” of the group. (Jason Aldag/The Washington Post)

A teenage Afghan asylum seeker who police say carried out an ax attack on a German commuter train pledged allegiance to the Islamic State before he set out on his mission, fueling a roiling debate in Germany about whether a historic influx of migrants has imported conflict from the Middle East to the undulating hills of Bavaria.

The Islamic State released a video it said the teenager made before using an ax and knife to injure five people, leaving two of them with “acute, life-threatening wounds,” according to an investigator. In the video — recorded in what appeared to be the bedroom of his foster residence — he vowed to create so much destruction that he would wipe out memories of Thursday’s attack in Nice, France, which claimed 84 lives.

The revelation that the attacker, killed by police and identified by security officials only as “R.A.,” was an Afghan migrant who registered in Germany in June 2015 ignited fresh questions about whether Chancellor Angela Merkel’s open door last year to migrants had imperiled her nation’s security and overtaxed its ability to integrate them. Politicians and analysts said the attack was likely to further sour German citizens’ attitudes toward the newcomers in their midst.

“With an ax on a moving regional train. How often did this happen in the 20th century, and why not?” wrote Marcus Pretzell, a member of the Alternative for Germany party who is a lawmaker in the European Parliament, on Twitter. Pretzell has advocated using armed force to defend Germany’s border from asylum seekers.

Authorities say some of the victims were critically injured when a man attacked passengers on a train in Bavaria, but the motive for the attack is still unclear. (Reuters)

Analysts said that Monday’s attack may be a turning point in Germany’s discussion about migration, particularly since anger had already grown following sexual assaults on New Year’s Eve in Cologne on about 1,200 women. Those attacks were largely blamed on men of North African and Arab origin.

“The climate of the debate will change,” said Heinrich Oberreuter, a political scientist at the University of Passau. “The federal government will be forced to put the problem of internal security into the center of its refugee policy.”

Germans initially greeted asylum seekers with roses, clothing and sustenance during peak arrivals late last year. But a series of attacks and assaults linked to immigrants has changed attitudes and sent Merkel’s approval rating plummeting ahead of 2017 elections. Merkel and her allies have since sought to harden Europe’s borders, and they have acknowledged missteps in how they handled the influx of more than 2 million people, the largest since 1950.

The anti-immigrant Alternative for Germany party, meanwhile, has been surging at the polls.

There were few reassurances Tuesday from German leaders, who were left to deal with the consequences of the second Islamic State-linked attack in Europe in less than a week, following the Bastille Day truck attack in Nice. Even though the militant group claimed responsibility for both strikes, investigators have not yet found evidence that it directed either attack. 

How terrorism in the West compares to terrorism everywhere else

“In principle, such acts can already be perpetrated every day in every place, more or less worldwide,” said Joachim Herrmann, interior minister for the state of Bavaria. “We are not safe.”

In a measure of the political sensitivity of the incident, he warned against “sweeping judgments” about refugees.

Merkel has acknowledged that militants used the migrant route last year to smuggle themselves into Europe, creating the biggest challenge yet to her 11-year rule. Refugee flows have since halted after a deal with Turkey to house more people there.

“Our structures were overwhelmed,” said the powerful ­center-left leader of the North Rhine-Westphalia region, Hannelore Kraft, who last year was far more welcoming toward asylum seekers. “That’s why I am glad that our borders are tight for the first time,” she told the WDR broadcaster in comments published hours before the train incident.

The attacker arrived in Germany last year as an unaccompanied minor and registered his asylum claim in March, authorities said Tuesday. He lived in a group home for underage asylum seekers in Bavaria starting in March before moving in with a foster family near Würzburg two weeks ago. 

Prosecutors said the teenager had just learned of a friend’s death in Afghanistan over the weekend. In a Pashto-language note found in his bedroom, he vowed to “take revenge on these infidels,” investigators said. Investigator Lothar Koehler said that the teenager posted a cryptic online message about the “enemies of Islam” hours before the attack.

When searching his house, investigators also found a notepad with a drawing of the Islamic State flag and what they believe to be a farewell note to his father. In the video, issued by the Islamic State’s Amaq news agency, a young man identifies himself as a “soldier of the caliphate” and threatens further attacks by the group “in every village, city and airport,” according to a translation by the SITE Intelligence Group, which tracks jihadist organizations.

“I lived among you and in your houses. . . . I will slaughter you in your houses and tear you apart,” he said, gesturing with a kitchen knife about three or four inches long.

An unnamed police official told the German DPA news agency that authorities believed that the man in the video was the attacker. German authorities said they found no evidence of direct communication between the militant group and the attacker.

The Islamic State said that the teen was a “fighter” for the group, the Amaq agency said. Islamic State leaders have called on followers to strike Western targets even without direct support or approval from the group’s formal structures. If an attacker pledges allegiance to the group before an attack, the Islamic State will typically claim the violence as its own.

Herrmann said acquaintances had not seen any outward indications of changes in behavior or views by the teen, suggesting that he may have “suddenly reoriented in a short period of time.” Acquaintances described a “calm” and “well-adjusted” young man who attended a mosque on religious holidays but showed no signs of extremism, Herrmann said.

Police could hear a male shouting “Allahu akbar” — Arabic for “God is great” — when a passenger on the train called them during the attack, investigators said.

On Monday around 9 p.m., the teenager boarded the commuter line that runs from Treuchtlingen to Würzburg in the southern German province of Bavaria. The train, carrying 20 to 30 passengers, had just pulled out of the station when the youth began his attack, wielding the ax to strike heavy blows to the heads of his victims, Herrmann said. 

Four people suffered injuries before the assailant fled from the train when someone pulled its emergency brake in the town of Heidingsfeld, a suburb of Würzburg. As he ran, he attacked a woman who was walking her dog, seriously injuring her. A specialized police unit that happened to be in the area found him on the bank of the Main River and fatally shot him. 

The people injured on the train were members of a family from Hong Kong, Herrmann said, and one of them remained in serious condition.

Birnbaum reported from Brussels.