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.
- Trump Waives Shipping Regulations to Aid Puerto Rico
- Canada: Five injured in suspected terror attack in Edmonton
- Malaysia GP: Lewis Hamilton's sleepless night ends in dream qualifying
- NRL Preview grand final: Brett Kimmorley verdict, TAB odds
- Klitschko faces must-win bout against Fury
- Unions lambast Supreme Court decision to hear mandatory union fee case
- United and City looking to create El Classico in Manchester
- Republicans Introduce 'SUCCEED Act' to Protect Undocumented Children
- Marcus Rashford: Manchester United youngster makes defender look foolish
- Prince Harry and Barack Obama's bromance is blossoming beautifully