German police shot dead a 17-year-old Afghan late Monday after he attacked train passengers with an axe and a knife, seriously wounding three people in what one official said was a "probable" Islamist attack.

Several other people were also injured in the attack on a regional train near the southern city of Wuerzburg, police said, adding that the teenager was killed as he tried to flee.

Joachim Herrmann, the interior minister of Bavaria state, said the attacker was a 17-year-old Afghan who had lived in nearby Ochsenfurt.

“It is quite probable that this was an Islamist attack,” said a ministry spokesman, adding that the attacker had shouted “Allahu akbar” (God is greatest).

The attack happened around 9:15 pm (1915 GMT) on the train, which runs between Treuchlingen and Wuerzburg in Bavaria.

“Shortly after arriving at Wuerzburg, a man attacked passengers with an axe and a knife,” a police spokesman said.

“Three people have been seriously injured and several others lightly injured.”

He added: “The perpetrator was able to leave the train, police left in pursuit and as part of this pursuit, they shot the attacker and killed him.”

There were no further details on the circumstances of the teenager’s death.

In May, a mentally-unstable 27-year-old man carried out a similar knife attack on a regional train in the south, killing one person and injuring three others.

Early reports suggested he had yelled “Allahu akbar” but police later said there was no evidence pointing to a religious motive. He is being held in a psychiatric hospital.