The Islamic State claimed responsibility for the attack several hours later, calling the assailant one of its “soldiers.”
The group’s Amaq news agency said the man had been inspired by calls to carry out attack in Western countries. In 2014, ISIS called on sympathizers to commit violence using any means available, including stabbings, in those countries whose militaries were fighting the terror group in Iraq and Syria.
The group’s claim of responsibility could not be independently verified.
Asked about reports that the attacker yelled “Allahu akbar,” or “God is greatest” in Arabic, at the moment of the attack, Jean-Claude Gaudin, the mayor of Marseille, said that “a certain number” of witnesses had said they heard him do so, but he added that they were still being interviewed by the police for further details.
“We have video images that will enable us to assess the situation,” Mr. Collomb said, referring to security camera footage in the station. “What is strange on the video is that the person starts to commit his crime on a first person, then he runs away, and then he turns back to kill the second person.”
A military patrol that had rushed to the scene after hearing cries of panic and seeing people running fired warning shots at the attacker, Mr. Collomb said, and then shot and killed him when he rushed at them.
Soldiers and armed police officers with protective gear barred access to the train station for much of Sunday afternoon, and the national railway operator urged travelers to avoid the station, but the authorities said later in the day that train service was slowly returning to normal.
France has been on high alert for acts of terrorism since 2015, after a string of attacks that killed more than 230 people. The deadliest attack was an assault in November 2015 by coordinated teams of Islamic State operatives who killed 130 people in and around Paris, prompting officials to declare a state of emergency.
Newsletter Sign Up
Thank you for subscribing.
An error has occurred. Please try again later.
You are already subscribed to this email.
The state of emergency, which enables the authorities to raid homes and place people under house arrest without the authorization of a judge, has been renewed several times and will end on Nov. 1.
But Parliament is expected to vote soon on a bill that would give security forces additional powers, some similar to those in the state of emergency, to monitor suspects, conduct raids and search bags or vehicles. Civil rights groups have criticized the legislation.
In a statement on Sunday evening, Édouard Philippe, the French prime minister, expressed “anger and outrage” after the attack and praised the soldiers who had “neutralized the criminal and stopped his killing spree.”
“We will not drop our guard,” Mr. Philippe added on Twitter.
So far in 2017, there have not been large-scale attacks like the ones that struck Paris in 2015 and Nice in 2016, but France has grown wearily accustomed to smaller, sporadic attacks, especially against police officers and soldiers patrolling sensitive or crowded sites.
In September, a man wielding a knife was arrested after he attacked a military patrol in one of the biggest metro stations in Paris; but no one was injured. In August, a driver plowed into a military patrol in Levallois-Perret, a suburb just north of the capital, injuring six soldiers.
Other attacks have been carried out by mentally ill residents, who sometimes imitate acts of terrorism, according to officials.
In August, a man with a history of psychiatric disorders rammed a vehicle into two bus stops in Marseille, killing one woman, but the authorities said the episode was not related to terrorism.
In September, four American college students traveling through the Saint-Charles station were attacked with acid by a psychologically disturbed woman, officials said.