Two women were stabbed to death and their assailant shot dead by soldiers at the main train station in the southern port city of Marseille on Sunday in an attack claimed by the Islamic State (IS) group.

The two victims – one aged 17 and the other 20 – suffered extensive injuries, two police sources said, saying one had her throat slit while the other was stabbed in the stomach.

Three police sources said the suspect had shouted "Allahu Akbar" (God is greatest) as he carried out the attack.

Some 200 police officers had cordoned off the area and all roads were closed to traffic, with security forces saying the operation was still ongoing.

The IS group claimed the attack through a statement posted by its Amaq propaganda agency late Sunday, according to the SITE monitoring group.

It quoted a security source as saying: "The executor of the stabbing operation in the city of Marseille ... is from the soldiers of the Islamic State."

French President Emmanuel Macron expressed his outrage at the Marseille attack on his Twitter account and praised the reaction of the security services, including the Opération Sentinelle soldiers deployed to deal with such domestic threats.

"I hail the Opération Sentinelle soldiers and the police forces who reacted with extreme calmness and efficiency," Macron wrote on Twitter.

France has been under a state of emergency following a spate of attacks by Islamist militants over the last few years, including coordinated attacks in Paris in November 2015 that killed almost 130 people. Other countries – including Britain, Germany and Belgium – have also been targeted in attacks using knives, guns, explosives and vehicles.

A witness told Reuters she saw a man take out a knife from his sleeve and then stab a young girl and then a second woman. She said soldiers from France's Sentinelle force who were patrolling the area soon arrived on the public square at the Gare Saint-Charles station.

Two police sources said the attacker had been carrying a butcher's knife, was around 30 years old and of North African appearance. One of the sources said no identification papers were found on him.

French Interior Minister Gérard Collomb said he was heading to the site of the attack.

Meanwhile, the SNCF railway operator urged people to avoid all travel to the transport hub. Some 200 trains have been diverted or are waiting at regional stations.

Speaking to FRANCE 24, Marseille's city councillor Patrick Mennucci said he did not believe Marseille was specifically targeted. "The latest information on the risks of a terror attack show that the town is not a particular target."

Regional president Renaud Muselier, who was speaking from the site of the attack, told BFM TV: "We have generally avoided these sort of attacks in Marseille."

"I think the security services responded extremely quickly. It's difficult to do more because when you see the distance between the two bodies and the attacker it's only 10 metres, so they intervened quickly."

Security forces have also increasingly been targeted by militants, most notably in June 2016 when a Frenchman who pledged allegiance to the Islamic State group stabbed a police commander to death outside his home and killed his partner.

French lawmakers are due to vote on a much-criticised anti-terrorism law on Tuesday, which would enshrine some state-of-emergency powers into law and could reduce the number of military personnel on the ground.

"The presence of Sentinelle soldiers, their speed and efficiency ensured that the death count was not bigger," police union official Stéphane Battaglia told Reuters.

"Sentinelle is an essential addition to the security forces during the state of emergency and the fight against terrorism," he said.

Councillor Mennucci said that the proposed anti-terrorism bill can only go so far.

“No bill, no matter how security-focused, could totally eliminate the madness that seizes an individual who wants to kill or massacre [people].”