A man wielding a knife has attacked residents of a French town while they ventured out to shop amid a nationwide coronavirus lockdown, killing two people and wounding five others in an act that led authorities to open a terrorism inquiry.

France’s counter-terrorism prosecutor’s office said the suspect was arrested near the scene of the attack in the town of Romans-sur-Isere, south of Lyon, as he was kneeling on the pavement praying in Arabic.

It said one of his acquaintances was also detained.

Prosecutors did not identify the suspect.

Police officers investigate after a man wielding a knife attacked residents venturing out to shop under lockdown  in Romans-sur-Isere, southern France
Police officers investigate after a man wielding a knife attacked residents in Romans-sur-Isere, southern France (AP)

They said he had no identifying documents but claimed to be Sudanese and to have been born in 1987.

During a subsequent search of his home, authorities found handwritten documents that included arguments about religion and a complaint about living in a “country of unbelievers”, officials said.

The prosecutor’s office did not confirm reports that the man shouted “Allahu akbar” (God is great) as he stabbed and slashed people.

Like the entire population of France, Romans-sur-Isere’s residents have been ordered to stay home, apart from a few exceptions.

The victims were doing their food shopping, one of the permitted outside activities, on the street that has bakeries and grocery stores, the prosecutor’s office said.

French media reported that the knifeman first attacked a man who had just left home for a daily walk – slitting his throat in front of the victim’s girlfriend and son.

Police officers investigate after a man wielding a knife attacked residents venturing out to shop under lockdown in Romans-sur-Isere, southern France
Police at the scene in Romans-sur-Isere (AP)

Next, the assailant went into a tobacco shop, stabbed the tobacconist and two customers, and then went into the local butcher’s shop, according to French news reports.

He grabbed another knife and attacked a customer with the blunt end before entering a supermarket, the media said.

Some shoppers took refuge in a nearby bakery.

French interior minister Christophe Castaner arrived at the scene in the town within hours and thanked shopkeepers for their help.

Some 100 police and 45 firefighters were involved in the operation and securing the area, authorities said.

There have been a number of knife attacks in France in recent months.

Police officers investigate after a man wielding a knife attacked residents venturing out to shop under lockdown in Romans-sur-Isere, southern France
The town is in lockdown along with the rest of France (AP)

In January, French police shot and injured a man in Metz who was waving a knife and shouting “Allahu akbar”.

Two days earlier, another man was shot dead by police after he stabbed one person fatally and wounded two others in a Paris suburb.

It is unclear whether the suspect in Saturday’s attack had psychological problems or any links to extremism.

Analysts say some extremist groups see the upheaval from the virus pandemic as an opportunity to win over more supporters.