Blood stains and a rescue blanket are seen through the windows of a train in Wuerzburg, southern Germany, Monday evening, July 18, 2016, after a 17-year-old Afghan armed with an ax and a knife attacked passengers aboard a regional train in southern Germany on Monday night, injuring four people before he was shot and killed by police as he fled. (Karl-Josef Hildenbrand/dpa via AP)

BERLIN (AP) — The Islamic State group claimed responsibility Tuesday for an ax-and-knife attack on a German train that left at least five people injured, but authorities said it appears the 17-year-old Afghan asylum seeker who was shot and killed by police as he fled the scene appears to have self-radicalized and had no direct link to the extremists.

The teenager shouted “Allahu akbar” (“God is great”) as he attacked people on the regional train near the Bavarian city of Wuerzburg Monday night, and a hand-painted flag of the Islamic State was found during a search of his room, according to state Interior Minister Joachim Herrmann.

Though the Islamic State group claimed responsibility through its Aamaq news agency, Herrmann said the suspect, whose identity has not been released, had written notes in his native Pashto that indicated he may have been self-radicalized and there was “no indication” he was directly connected to the IS group.

Herrmann said people close to the attacker told investigators he had seemed like a calm person, not overtly religious or an extremist.

Herrmann said investigators were still looking into the evidence found in the teenager’s room, saying it could be possible that the notes included a farewell letter to his father.

“There are hints that he — in a text — writes about the lives of Muslims, but also that Muslims must take action on their own and resist now,” Herrmann said.

The 17-year-old attacked at least four passengers with an ax and knife on a train near Wuerzburg-Heidingsfeld on Monday night, but was shot and killed by a special police unit which happened to be nearby.

Four people on the train were injured, along with a woman outside as the attacker fled.

Herrmann said that it was too early to draw conclusions about the attacker’s motive.

German officials did not identify the victims, but Hong Kong’s immigration department said that among those injured in the attack were four members of a family of five from the southern Chinese city.

The university hospital in Wuerzburg confirmed that it was treating two patients from Hong Kong with life-threatening injuries.

Hong Kong’s top official, Chief Executive Leung Chun-Ying, condemned the attack and extended his sympathies to the victims and their families.

Herrmann said it was a tragedy that a “family from Hong Kong comes here as tourists to visit Wuerzburg … and then becomes victim on a train here in Bavaria in an attack conducted by an offender who came from Afghanistan and who was originally seeking shelter here.”

The dpa news agency reported that the attacker injured the 62-year-old father, the 58-year-old mother, their adult daughter and her boyfriend. The teenage son was not injured. The father and the boyfriend had tried to defend the other family members, dpa said.

The mayor of Wuerzburg condemned the attack.

“I’m shocked by this horrible act of violence,” Christian Schuchardt said adding that his thoughts were with the victims and other passengers “who have suffered severe injuries on their bodies and souls by this act of craziness.”

The assailant jumped off the train after someone pulled the emergency cord and got about 500 meters (yards) into Wuerzburg-Heidingsfeld, attacked a woman there with his ax and ran away before the police special unit chased him. As police drew near, the assailant started attacking the officers and was shot, according to Herrmann.

Prosecutor Christopher Rosenbusch in nearby Bamburg, who is in charge of the investigation, said he could give no further details on the injured people, including the woman who was attacked outside the train.

Witnesses said the interior of the train was covered with blood and looked “like a slaughterhouse,” the German news agency dpa reported. About 30 passengers were on the train at the time; more than a dozen were treated for shock.

On Tuesday morning, officers could be seen removing the attacker’s body from the scene.

The attacker came to Germany more than a year ago as an unaccompanied minor, was first registered by German authorities in the German-Austrian border town of Passau and applied for asylum in March of last year. He lived in a home for young refugees in Ochsenfurt near Wuerzburg until two weeks ago when he was placed with a foster family in the same town, Herrmann said. Investigators were talking to the foster family, witnesses and the attacker’s friends.

According to dpa, the attacker was interning at a bakery and had good chances of getting into a job training program.

Germany last year registered more than 1 million asylum seekers entering the country, including more than 150,000 Afghans.

In May, a man stabbed four people at a German train station in a random early-morning attack in Grafing near Munich. One man later died. The attacker, a German citizen, also shouted “Allahu akbar” during the attack, but authorities found no evidence of links to Islamic extremists. He was later sent to a psychiatric hospital.