A man who allegedly killed at least one person and injured three more at a train station in the town of Grafing near Munich, while reportedly shouting “Allahu Akbar,” had no Islamist motive, officials said, adding the suspect won’t stand trial as he has mental health issues.

The incident took place early on Tuesday. German media cited local witnesses who claimed that the knife-wielding man started attacking people at the station, shouting “Allahu Akbar” and “infidels.”The attacker was arrested on the spot.

One of the victims, a 56-year-old man, later succumbed to his injuries in hospital, the prosecutor said. He added that “two people are badly wounded, one is in critical condition.” The three injured are aged 58, 43 and 55.

The authorities quickly closed the station following the attack. “The station is a crime scene,” a police spokesman told the Sueddeutsche Zeitung, adding that specialists will be working there. The police also announced media ‘blackout’, German press reported.

The “assailant made remarks at the scene of the crime that indicate a political motive - apparently an Islamist one,” Ken Heidenreich, spokesman for the prosecutor's office, told AFP. “We are still determining what the exact remarks were.”

The name and nationality of the attacker was then revealed to the public by German media as being 27-year-old Paul H. from the city of Hesse in central Germany. The attacker reportedly does not have a migrant background.

Heidenreich told AP that the prosecutor’s office was investigating witness reports that claimed the suspect had yelled “Allahu Akbar.”

Later, senior police official Guenther Gietl told media that a woman who witnessed the incident heard the attacker shout “infidel, you must die" at the time of the stabbing.

The authorities later said there were no Islamist motives in the attack and the man was probably a drug addict and suffered from mental health issues.

The nationality of the attacker was confirmed by the interior minister of the state of Bavaria, Joachim Herrmann.

“When it comes to revealing more about their background, or whether mental illness or drug addiction played a role, these are things that require further clarification. I think we will make further announcements on this later in the day.”

Herrmann later said that the man apparently had mental health problems and drug issues.

Following questioning of the suspect, the authorities said they found him to be not mentally fit for trial.

According to senior police official Lothar Koehler, the man made a “rather confused impression” during questioning. For example, the man said he had taken his shoes off because “he felt bugs on his feet that had caused blisters and were generating intense heat,” Koehler said.

The man might have taken drugs days before the attack, the officer said, adding that police found no previous narcotics cases against the alleged assailant.

Koehler added that the suspect apparently had no accomplices or connections with extremists.

Grafing, a small town of 12,000 people, is in shock over the incident.

“Something like this is absolutely new and shakes people deeply, otherwise, they only know this kind of thing from television,” Mayor Angelika Obermayr said. “That it could happen here is absolutely shocking.”

Germany has so far seen two attacks with apparent Islamist motives. In February, a 15-year-old girl, named as Safia S., stabbed a police officer at the main train station in Hannover. According to prosecutors, the girl had “embraced radical jihadist ideology of the foreign terrorist group Islamic State of Iraq and Syria [IS, formerly ISIS/ISIL].”