German authorities have cast doubt on whether a teenager who went on an axe rampage on a Bavarian train was really an Afghan refugee, saying he might have been from Pakistan.

Key points: Attacker may have pretended to be Afghan to secure asylum

Attacker may have pretended to be Afghan to secure asylum It is believed he was inspired by IS but not part of the network

It is believed he was inspired by IS but not part of the network Locals described the attacker as "calm and even-keeled"

Interior Minister Thomas de Maiziere said the teenager was believed to be a "lone wolf" attacker who appeared to have been "inspired" by the Islamic State group, but was not a member of the jihadist network.

"This is perhaps a case that lies somewhere between a crazed rampage and terrorism," Mr Maiziere told reporters.

He said investigators were still trying to determine the true identity of the 17-year-old, who was shot dead by police after he injured five people, two of them critically.

The Islamic State group released a video on Tuesday purportedly featuring the assailant announcing in Pashto he would carry out an "operation" in Germany, and presenting himself as a "soldier of the caliphate".

German authorities said they had authenticated the video.

However, security service sources now think he might have pretended to be Afghan on arrival in Germany in 2015 in order to have a better chance of securing asylum, German media reported.

In the IS video the youth uses phrases of a dialect of Pashto spoken in Pakistan — not Afghanistan — and experts have indicated his accent is Pakistani.

A Pakistani document was also found in his room.

Mr Maiziere noted however both Afghanistan and Pakistan had Pashtun communities and said German authorities had received an application for family reunification from the teenager for relatives in Afghanistan.

Authorities investigate ties to Islamic State

Mr Maiziere said investigators were also looking closely at accounts from the assailant's foster family that he received a phone call on Saturday informing him of the death of a friend in Afghanistan, and considering whether his apparent distress over the news was a trigger for the attack.

Authorities on Tuesday found a hand-painted IS flag and what they called a suicide letter addressed to his father among the attacker's belongings.

Locals described the assailant as "calm and even-keeled" and a "devout Muslim who did not appear to be radical or a fanatic", according to Joachim Herrmann, Interior Minister of Bavaria state.

Police however said he wrote in the letter that the world's Muslims "must defend themselves".

"Now pray for me that I can take revenge on non-believers, pray for me that I can get to heaven," the note said.

Prosecutors said he shouted "Allahu akbar" (God is greater) three times as he rampaged through the carriage.

Germany has thus far escaped the kind of large-scale jihadist attack seen in the southern French city of Nice last week, in which 31-year-old Mohamed Lahouaiej Bouhlel used a truck to mow down 84 people.

That attack was also claimed by IS without the assailant having clear ties to the group.

AFP