A teenage Afghan refugee armed with an axe and knife injured four people on a train in southern Germany before being shot dead by police, officials say.
Three people in a group from Hong Kong were seriously hurt and one slightly injured in the attack in Wurzburg. Another 14 were treated for shock.
Bavarian Interior Minister Joachim Herrmann said the attacker was killed as he tried to flee the scene.
Mr Herrmann said the attacker was a 17-year-old Afghan refugee who had been living in the nearby town of Ochsenfurt. He told public broadcaster ARD that the teenager appeared to have travelled to Germany as an unaccompanied minor.
Although the motive has not been established, the BBC's Damien McGuinness in Berlin says there is nervousness in Germany about attacks by Islamist extremists following the attacks across the border in France.
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.