BERLIN — A 27-year-old German killed one man and injured three others with a knife while shouting “Allahu akbar” in a suburb of Munich early Tuesday, but hours later, after questioning him, the authorities said that he had no known links to Islamic extremism and that they believed he was mentally disturbed.

The attack, which occurred shortly before 5 a.m. on a commuter train and platform in the bucolic suburb of Grafing, nearly 20 miles east of Munich, shocked and unsettled many Germans who had already been on edge since the terrorist attacks in and around Paris on Nov. 13 and at an airport and a subway station in Brussels on March 22. The authorities responded swiftly to calls for help, and the man was arrested shortly after carrying out the attacks.

The lead investigator for the Bavarian state police, Lothar Köhler, told reporters on Tuesday afternoon that after initial questioning of the suspect, whom the authorities did not identify, officials had no “compelling evidence or plausible conclusions” as to a motive.

“We have no indication that he had any contact to Islamic or Salafist groups, individuals or organizations,” Mr. Köhler said. The investigator confirmed that witnesses had heard the attacker shouting “Allahu akbar” — “God is great” — and, in German, “You infidels must die,” but as the context emerged, the attack seemed less and less likely to be motivated by extremism.