Paris prosecutor Francois Molins told reporters the two suspects "were getting ready to carry out an imminent, violent action" on French territory.
Police in the southern coastal city said they had "neutralized" the assailant and cordoned off the area.
French police officers block access on the stairs leading to Marseille 's main train station.
The attacker's fingerprints showed he had had seven brushes with the law since 2005 - most recently when he was arrested last Friday in Lyon for shoplifting. Both victims in this terrorist attack were women. "I heard someone shout "Allahu Akbar" and I saw a man who seemed to be dressed all in black".
While France has been hit by a string of terror attacks in recent years there have also been deadly incidents which investigators concluded were motivated more by the attacker's psychological disorders than terrorism, notably when a man rammed his vehicle into a bus stop in Marseille last August. But no firm evidence has surfaced linking the man to Islamic extremism.
The attacker was known to police for delinquency, though not followed by anti-terrorist teams, according to France Info radio. He said the assailant's "strange" behaviour of attacking, running away and then returning to strike again was "a point of inquiry".
A woman passer-by tried to intervene, Molins said.
Later that evening, police at a checkpoint identified a man driving a U-Haul vehicle as the owner of the Malibu.
The suspect was shot by a military patrol after killing two women, the police said.
"The presence of Sentinelle soldiers, their speed and efficiency ensured that the death count was not bigger", police union official Stephane Battaglia said. French President Emmanuel Macron intends to introduce a new bill permanently enshrining counterterrorism measures, which he claims will sufficiently replace the state of emergency.
The IS-linked Aamaq news agency said in a statement on Sunday night that the assailant was acting in response to IS calls to target countries in the US-led coalition fighting IS extremists in Syria and Iraq. "We are traumatized, we are all anguished".
239 people have been killed since 2015 in France by militants. All four of the intended victims were students at Boston College. The mayor said their identities would not be released to save the families further trauma.
- Prince Harry and Barack Obama's bromance is blossoming beautifully
- OJ Simpson released on parole after nine years in Nevada prison
- Best ways to make your website stand out from the rest
- Two more for Kane as Spurs hit four at Huddersfield
- Republicans Introduce 'SUCCEED Act' to Protect Undocumented Children
- Trump lashes out at San Juan mayor over Maria response
- Marilyn Manson injured by falling prop at NYC show
- Defoe strengthens Euros case
- Unions lambast Supreme Court decision to hear mandatory union fee case
- Talent Not an Issue for England's New Manager