Four passengers on a train in southern Germany were wounded, three of them seriously when a 17-year-old Afghan refugee suddenly attacked them with an axe and a knife.
Police chased after the youth when he fled the train at an emergency stop but say they were forced to shoot him dead when he tried to attack an officer.
Fourteen other passengers were treated for shock.
A hand-drawn ISIL flag was later found in the man’s room.
The youth is said to have been living in a home for unaccompanied minors in Ochsenfurt, near the city of Wurzburg.
The incident happened at about 9 pm local time on the train which runs between Treuchlingen and Wurzburg in Bavaria.
German media sources have unconfirmed reports that the youth shouted Allahu Akbar or “God is Great” during the attack. Germany is on alert for Islamist extremists following the attacks across the border in France.
In May, a man reportedly shouting “Allahu akbar” killed one person and wounded three others in a knife attack at a railway station near Munich. He was later sent to a psychiatric hospital and authorities said they found no links to Islamic extremism.
Germany welcomed roughly 1 million migrants in 2015, including thousands of unaccompanied minors. Many were fleeing war in countries like Syria, Iraq and Afghanistan.