The attacker who critically wounded three people in a slashing attack aboard a German train was a 17-year-old Afghan, Bavarian Interior Minister Joachim Herrmann has told local broadcaster ARD.
The attacker was shot and killed by police.
German media quoted a Bavarian ministry official as saying he was a refugee.
The teenager was armed with an axe and knife when he attacked passengers on the train near Wuerzburg in Bavaria, in the country's south.
Wuerzburg police said on their Facebook page that three of the victims suffered serious injuries and one was slightly injured. Another 14 people were being treated for shock.
The train was on its way from the Bavarian town of Treuchtlingen to Wuerzburg, which is about 100 kilometres northwest of Nuremberg.
The rail line between Wuerzburg-Heidingsfeld and Ochsenfurt has been closed, the police spokesman said.
There was no indication of the motive for the attack.
