A stabbing attack at a railway station in southern Germany by a man who eyewitnesses said shouted "Allahu Akbar" injured at least three people and killed one on Tuesday morning.

While police initially said they were focusing investigations on whether there was an Islamist motive to the attack, evidence later emerged suggesting that the assailant, who appears to have carried out the attack barefoot, was psychologically unstable.

Two of the victims were seriously injured and a third is in a critical condition, according to local media reports.

A police spokeswoman said officers had detained a 27-year-old male suspect who was overpowered at the scene.

German news outlets have identified the assailant as Paul H, a resident of the town of Hessen in the center of the country, and German newspaper Sueddeutsche Zeitung reported traces of drugs were found in a container by investigators at the scene. These reports have not been officially confirmed.

Bavarian Interior Minister Joachim Herrmann said that police had found "no indication" that there was an Islamist motive behind the attack so far, and that officers were investigating whether the man suffered from mental health and drug addiction problems.

Karl-Heinz Segerer, spokesman for the state office of criminal investigation, said that the man's stabbing rampage began inside the train, and that the assailant then continued to attack individuals, apparently at random, on the platform and square outside the station.

According to local media reports four people, including two cyclists and a newspaper boy, were attacked inside the carriage. Video footage and photographs of the aftermath showed a trail of bloody footprints on the station platform which was cordoned off by police.

A 56-year-old died of stab wounds in hospital shortly after the attack. The other stabbed men, aged between 43 and 58, sustained lighter injuries, police said. The incident took place at around 4.50am local time at a commuter train station in Grafing, a town around 20 miles southeast of Munich.

"The idea that people enter on a beautiful morning in the S-Bahn or do their newspaper round and then become victims of a maniac, is terrible," Grafing mayor Angelika Obermayr told Sueddeutsche Zeitung. "I am most grateful for the police, doctors, paramedics, and our firefighters who were quickly on the scene."

Local media outlet Merkur reported that the assailant had been identified as a German citizen and that police were imposing a news blackout.

While Germany has not experienced terror attacks on the scale of recent attacks in France and Belgium, the country's security services are on alert and the government has warned of threats.

Over 800 homegrown radicals have left Germany to join jihadist groups in Syria and Iraq and about 260 have returned.

Germany has also been a transit country for militants who carried out attacks in Belgium this year and Paris last year.