The attack happened on the train line between Wurzburg and Heidingsfeld. The site is between Frankfurt and Nuremberg.
The attack took place as the train was traveling between stations. The train made an emergency stop short of the station at Wurzburg-Heidingsfeld and the assailant jumped out of the train.
Police hunted the man down with ground searchers and a helicopter.
The assailant, armed with a knife and an ax, was identified as a 17-year-old Afghan man living in Ochsenfurt, Bavaria, according to Bavarian Interior Minister Joachim Herrmann.
The ax-wielding man has been shot dead by police, according to Lt. Fabian Hench, regional police spokesman.
Four passengers who were attacked are in serious condition, with the total number of wounded unclear, although over 20 injured is reported by police and others. The attacker's motive is not yet known, Hench said.
The early 600s AD name Uburzis that was used at the same time as Würzburg is presumably of Celtic origin. Based on a folk etymological connection to the German word Würze "herb, spice," the name was Latinized as Herbipolis in the medieval period
The Würzburg witch trials, which occurred between 1626 and 1631, are one of the largest peace-time mass trials. In Würzburg, under Bishop Philip Adolf an estimated number between 600 and 900 alleged witches were burned.
On 3 April 1945, Würzburg was occupied by the U.S. 12th Armored Division and U.S. 42nd Infantry Division in a series of frontal assaults masked by smokescreens. The battle continued until the final Wehrmacht resistance was defeated on 5 April 1945.