A man who fatally stabbed two young female cousins Sunday while reportedly shouting "Allahu Akbar" outside Marseille's train station had been detained for shoplifting and released the day before the attack, French authorities said.

The man also had seven fake identities, used in previous encounters with police, officials said Monday. One such identity named him as “Ahmed H,” born in 1987 in Tunisia.

French authorities are studying the suspect's cellphone and working to determine his true identity and whether he had direct links to ISIS, which claimed responsibility for Sunday's stabbing. The assailant was killed by soldiers immediately after the attack, the latest of several targeting France.

The suspect was identified by his fingerprints, which matched those taken during seven previous incidents registered by police since 2005, Paris Prosecutor Francois Molins told reporters.

The attacker didn't have any past convictions in France, Molins said. He did not elaborate on the previous police incidents, but noted the man's most recent arrest occurred in the Lyon area Friday — just two days before the train station stabbing.

ISIS CLAIMS RESPONSIBILITY FOR KNIFE ATTACK AT MARSEILLE TRAIN STATION

The man was held overnight for shoplifting, and then released Saturday and the charges dropped, Molins said. Molins said local authorities had no reason to hold him further based on the ID he gave them, a Tunisian passport.

He told Lyon authorities that he did odd jobs, used hard drugs and was divorced. It's not clear if the attacker had any connection to the victims, two cousins meeting for a birthday celebration in Lyon, Molins said.

Some witnesses reported hearing the assailant shout "Allahu Akbar!" — Arabic for "God is great" — and Molins said that's one of the reasons prosecutors opened a terrorism investigation.

He said video surveillance of the site showed the man arrived at the station in the early afternoon and sat for a few minutes on a bench outside. He then suddenly jumped up and stabbed one woman several times, then ran away, then came back and attacked the second woman.

4 AMERICAN TOURISTS ATTACKED WITH ACID IN MARSEILLE'S TRAIN STATION

A woman passer-by tried to intervene, Molins said. The man then tried to attack soldiers patrolling the site, but they shot him dead with two bullets.

The suspect was found with two knives and a telephone, but no identity papers, according to Molins.

The man's multiple pseudonyms made it difficult to even find a house to search for more clues, said Yves Lefebvre of the Unite SGP Police union.

"While it could shock the public, unfortunately it doesn't shock us, the police," that the suspect was released the day before carrying out a deadly attack, he said. He said shoplifting usually results in a quick police report and a court summons for a later date, and the suspect is released.

"Nothing allowed us to suspect there was a threat of radicalization during the [Lyon] arrest," Lefebvre told The Associated Press.

The ISIS-linked Aamaq propaganda outlet said the assailant was acting in response to the extremist group's calls to target countries in the U.S.-led coalition fighting militants in Syria and Iraq. France has been part of the anti-ISIS coalition since 2014. The Aamaq statement didn't provide evidence of a direct link to the attacker, and it's unclear if the claim is merely opportunistic.

The Associated Press contributed to this report.