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.

Mr. Molins said that the authorities in Lyon had wanted to initiate expulsion proceedings against the assailant, who was in France illegally, but could not. He did not specify why, but the newspaper Le Parisien reported later on Monday that the local detention center for people being processed for deportation was full. Agence-France Presse reported that the official who was supposed to be on duty to sign off on that procedure had been absent that day.

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.