Three people were seriously injured on Monday night after a 17-year-old Afghan refugee went on a stabbing rampage with a knife and an axe near the southern German city of Würzburg, some 280 kilometers (174 miles) north-west of Munich. The suspect was shot dead by police shortly after.

The incident occurred on Monday at around 9:15 p.m. local time (1915 UTC) on a regional commuter train traveling between the German towns of Treuchtlingen and Würzburg. Fourteen passengers were also treated for shock, while one other person sustained light injuries.

Watch video 00:40 Axe attack on German train

"Islamic State" (IS) flag found

Speaking on German television Tuesday, Bavarian Interior Minister Joachim Herrmann said investigators were making contact with people involved with the 17-year-old. He had been living in Würzburg since March, ina home for minors who had travelled to Germany unaccompanied to seek asylum. The foster family home where he had lived for the past two weeks was searched.

"A hand-painted IS flag was found in his room," Herrmann said.

"Islamic State" (IS) posted a video on Tuesday featuring an individual that the militant group identified as the perpetrator of the attack. In the clip the teenager is seen with a knife, saying he will use it to kill infidels.

Aamaq, a news agency linked to IS, said the group claimed responsibility for the attack and that the 17-year-old was its "fighter." The claim was phrased in a similar way to the IS response to the Bastille Day truck attack which killed 84 people in Nice, France last week.

Herrmann had earlier said