Mr. Molins said the two victims, whom he did not identify, were 20-year-old cousins, and that one was visiting the other from Lyon for the weekend. The University of Aix-Marseille confirmed on Monday that one of the victims was a medical student there.
The identity of the assailant remains unclear. Mr. Molins said that his fingerprints matched seven different identities that the man had provided in dealings with the French police since 2005.
Most recently, after being arrested in Lyon on Friday on suspicion of shoplifting, the man showed police officers a Tunisian passport that identified him as a 29-year-old named Ahmed H., Mr. Molins said. But the prosecutor cautioned that the authorities had not yet established whether the passport was real or whether it actually belonged to the suspect.
“This identity and the other aliases he used are not known to specialized antiterrorism services,” the prosecutor said. “Likewise, there are no past convictions in his criminal record to this day.”
The shoplifting case in Lyon was dropped because of insufficient evidence, and the man was released on Saturday — a day before the attack, Mr. Molins said. While in custody, the man had told officers that he was homeless, divorced and without a stable job, and that he used hard drugs.
The passport presented to the police in Lyon was not found on the assailant’s body in Marseille, Mr. Molins said. A small, stainless steel knife and a cellphone found at the scene are being analyzed by investigators.
Video from surveillance cameras showed the assailant arriving at the Saint-Charles train station at 1:32 p.m., Mr. Molins said, although it was not clear from where. He went to an open area in front of the station and waited on a bench for several minutes.
“At 1:45 p.m., he suddenly got up and headed toward the first victim, whom he stabbed several times, before running away,” the prosecutor said, adding that the assailant then circled back and attacked the second victim, who was hit by “several violent knife blows.” The knife used in the attack had a blade of about eight inches, or 20 centimeters, he said.
A bystander tried to stop the assailant by hitting him, Mr. Molins said. The attacker then headed toward a military patrol that had rushed to the scene, and was fatally shot.
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.
The country has been debating changes to its security apparatus ahead of the end of the state of emergency, first declared in late 2015 and renewed several times since. The lower house of Parliament is expected to pass a bill on Tuesday giving security forces more powers to monitor suspects, conduct raids and search bags or vehicles.
The attack in Marseille came as France prepared for the trial of a man suspected of involvement in what ended up being the first in a wave of terrorist attacks in the country by French-born extremists. The main defendant in the trial, which opened on Monday, is the older brother of an Islamic extremist who killed seven people in southwestern France in 2012.
Prosecutors say the defendant, Abdelkader Merah, 35, was complicit in the 2012 killings by his younger brother, Mohammed Merah. In March 2012, over several days in the Toulouse area, the younger Mr. Merah killed three paratroopers, followed by a teacher and three children at a Jewish school. He was killed in a standoff with the police.
Abdelkader Merah is accused of helping his brother prepare for the attacks, including by helping him steal a moped. Mr. Merah, who has been detained since his arrest in March 2012, has consistently denied knowing about his sibling’s plans.
Another defendant is also on trial on charges of helping Mohammed Merah obtain a bulletproof vest and weapons for the shooting.