Three people were seriously hurt and one suffered minor injuries in the attack in Wuerzburg, BBC quoted police as saying.
Initial reports said up to 20 people had been injured but it was later revealed that at least 14 had been treated for shock.
The identity of the attacker or the motive is not yet clear.
A Bavarian official quoted by German media said that the attacker was a 17-year-old Afghan refugee, but this was not confirmed.
A police spokesman at the scene said (in German) that the attacker had been shot dead while trying to flee.
The train line between Wurzburg-Heidingsfeld and Ochsenfurt has been closed.
This website uses cookies.