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 were seriously hurt and one suffered minor injuries in the attack in Wurzburg, police said. Another 14 were treated for shock.
Bavarian Interior Minister Joachim Herrmann said the attacker was killed as he tried to flee the scene.
The motive for the attack is not yet clear.
The injured include members of a family from Hong Kong, authorities there said, although their exact condition was not revealed.
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.
Mr Herrmann said authorities were looking into reports that the attacker had yelled out “an exclamation”. Some witnesses quoted by German media said they had heard him shout “Allahu akbar” (“God is great”) during the attack.
The incident happened at about 21:15 (19:15 GMT) on the train which runs between Treuchlingen and Wurzburg.
“Shortly after arriving at Wurzburg, a man attacked passengers with an axe and a knife,” a police spokesman said.
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 “looked like a slaughterhouse”.
He said he saw people crawl from the carriage and ask for a first-aid kit while other victims lay on the floor inside.
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.
He was later sent to a psychiatric hospital and authorities said they had found no links to Islamic extremism.