The so-called Islamic State has released a video purporting to show an Afghan asylum seeker making threats before attacking a German train.
The 17-year-old injured five people with an axe and knife, one critically, in the attack in Wuerzburg on Monday evening. He was shot dead by police.
In the video, a young man brandishing a knife says he is an "IS soldier" preparing for a suicide mission.
German officials say they later found a hand-painted IS flag in his room.
The teenager reportedly shouted the Islamic phrase "Allahu akbar" ("God is great") during the attack.
The self-styled news agency of IS said he had launched the attack "in answer to the calls to target the countries of the coalition fighting the Islamic State".
The attack comes days after a lorry ploughed into a crowd in Nice in France, killing 84 people. The self-styled Islamic State group said one of its followers had carried out that attack.
In the video, IS identified the attacker as Muhammad Riyad, who can be heard speaking Pashto.
Joachim Herrmann, the interior minister of the state of Bavaria, said the flag had been found among the teenager's belongings in his room in his foster home in the nearby town of Ochsenfurt.
A text written in Pashtun was also found, he said, and it showed a strong indication that the teenager "could be a person who had been self-radicalised".
Mr Herrmann said those who had interacted with the young man in recent months described him as calm and quiet and they could not understand his actions.
The teenager had gone to the mosque "on special occasions", he said, but no-one had noticed any radical behaviour and there were no signs yet of a direct link to jihadist networks.
Mr Herrmann said there was no indication Chinese citizens had been specifically targeted.
He also defended the police who shot the attacker, saying the teenager had run at officers brandishing the axe.
The Afghan teenager, who had claimed asylum after travelling to Germany a year ago as an unaccompanied minor, had been living with the foster family since moving from a refugee centre in the town two weeks ago.
Last year Germany registered more than one million migrants, including more than 150,000 Afghans, although the number has slowed dramatically this year since new EU measures were taken to stop the flow.
An ever-present division - Damien McGuinness, BBC News, Berlin
To get a feeling for the wider ramifications of this attack in Germany, you just need to take a quick look at Twitter in German. Racist and xenophobic comments against asylum seekers compete with equally impassioned arguments in support of refugees - including a tweet by Green MP Renate Kuenast asking why police had killed the attacker rather then injuring him.
This has provoked in turn another storm online, saying the perpetrator is getting more sympathy than the victims.
Over the past few months, since the EU agreed a deal with Turkey, numbers of migrants coming to Germany have dropped dramatically. And the issue has vanished from the front pages. The debate had shifted to a more nuanced one about how best to integrate the new arrivals. And the ferocity, fear and sometimes hate appeared to have dissipated. But the news that the attacker was an unaccompanied underage refugee shows that the division running through Germany about Angela Merkel's stance on refugees is still very much there.
The South China Morning Post said it was believed four of the people injured were a 62-year-old man, his 58-year-old wife, their daughter, 27, and her boyfriend, 31, from Hong Kong. The 17-year-old son travelling with them was not hurt, it said.
A source told the paper the father and boyfriend had tried to protect the other members of the group.
Hong Kong Chief Executive Leung Chun-ying has condemned the attack and expressed his sympathy to the victims. Immigration officials from the city will accompany family members to Germany.
Another woman was injured outside the train as the man fled. Fourteen people were treated for shock.
The attack happened at about 21:15 (19:15 GMT) on the train which runs between Treuchlingen and Wuerzburg.
Police said the attacker had fled the train but was chased by officers who shot him dead.
One local man told DPA news agency that the train carriage where the attack took place had "looked like a slaughterhouse".
In May, a man reportedly shouting "Allahu akbar" killed a man and wounded three others in a knife attack at a railway station near the German city of Munich.
He was later sent to a psychiatric hospital and authorities said they had found no links to Islamic extremism.
Were you on the train? Have you been affected by the incident? Tell us your experiences by emailing email@example.com.
You can also contact us in the following ways: