German police shot dead a 17-year-old Afghan refugee late Monday night after he attacked train passengers near the city of Wurzberg with an axe and a knife, seriously wounding three people, AFP reported.

While the motive for the attack is not clear, one official said the attack was a "probable" Islamist attack.

The teenager was killed as he tried to flee, according to AFP.

Joachim Herrmann, the interior minister of Bavaria state, said the attacker had arrived as an unaccompanied minor in Germany and was living nearby Ochsenfurt.

"It is quite probable that this was an Islamist attack," said a ministry spokesman, adding that the attacker had shouted "Allahu akbar" as he attacked the train passengers.

The attack happened around 9:15 p.m. Local time 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." Fourteen people were treated for shock.

Germany had thus far escaped the kind of large-scale jihadist attacks seen in the southern French city of Nice last week, in which 31-year-old Mohamed Lahouaiej Bouhlel used a truck to mow down people leaving a Bastille Day fireworks display, killing 84.

On Saturday, the Islamic State (ISIS) jihadist group claimed responsibility for the Nice attack, saying Bouhlel was “one of the soldiers of ISIS”.

In May in Germany, noted AFP, a mentally unstable 27-year-old man carried out a 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.