Three people were killed in southwestern France when a gunman held up a car, opened fire on police and then took hostages in a supermarket.
The man, earlier reported to be a 26-year-old petty criminal and small-time drug dealer, screamed "Allahu Akbar" before being shot dead as French police stormed the supermarket, in the small town of Trebes.
Islamic State (IS) claimed responsibility for the attack but offered no details.
The attacker from the nearby city of Carcassonne, named as Redouane Lakdim, was known to authorities but was not considered an Islamist threat, Interior Minister Gerard Collomb said, adding that he was believed to have acted alone.
More than 240 people have been killed in France in attacks since 2015 by assailants who pledged allegiance to IS or were inspired by the group.
"Every day we detect facts and foil new attacks. Alas, this one struck without us being able to counter it," Mr Collomb said.
Lakdim first killed one person with a bullet in the head while stealing a car in Carcassonne, which is one of France's top tourist attractions. He then shot at four police officers who were jogging before taking hostages at the supermarket in Trebes, about 8km to the east, where two people died.
"We had monitored him and thought there was no radicalisation," Mr Collomb said. "He was known for possession of drugs. We couldn't have said that he was a radical that would carry out an attack."
- Terrorism plot foiled, explosives seized in French raid
- French car attack suspect arrested
- Truck hits crowd in Nice, France
Five people were wounded in the attacks, including three seriously. Lakdim shot one police officer in the shoulder in Carcassonne, a walled hill top city which is a UNESCO World Heritage site.
BFM TV reported that he claimed allegiance to IS. Mr Collomb said the man had demanded the release of Salah Abdeslam, the prime surviving suspect in the IS attacks that killed 130 people in Paris in 2015.
Despite Mr Collomb's comments, Le Parisien newspaper wrote that Lakdim, a man of Moroccan descent, was known to French DGSI intelligence services. Without naming sources, it said he was active on Salafist social networks.
He was also suspected, without any certainty, of having travelled to Syria, Le Parisien said, adding that the family flat, where he would have been living with his parents and three or four sisters, was raided by police on Friday afternoon (local time).
"This is a small, quiet, town. Unfortunately the threat is everywhere," Collomb told reporters in Trebes.
Hostages hid from attacker in cold storage room
Witnesses said about 10 people in the supermarket found refuge in its cold storage room.
A lieutenant-colonel swapped himself in exchange for one of the hostages, Collomb said, adding that the 45-year-old had been seriously wounded.
French President Emmanuel Macron said the officer was fighting for his life in hospital.
By the time police stormed the building, the gunman was holding only the lieutenant-colonel.
One supermarket worker said some shoppers had escaped from the building after the gunman shouted "God is greatest" in Arabic. "I was in my department when I heard gunshots. I went to the area of the gunshots and came face to face with the person," said the employee, who gave his name only as Francois.
"He raised his gun and fired, I ran away, he shouted 'Allahu Akbar' and spoke about the Islamic State. I then evacuated the clients, about 20, who were in my area and we went quietly out of the back," said Francois.
Christian Guibbert described how he walked into the middle of the hostage-taking at his local supermarket and escaped only after the attacker, yelling "God is greatest" in Arabic, lunged at him with a knife.
Andre Bivent, 76, said he had finished his shopping and was on his way to the checkout when he heard shots and spotted Lakdim.
"I got down on the ground when I heard shooting a second time, and that's when I saw him walking among the checkout counters," Mr Bivent told Reuters.
Another shopper then led him to the cold room where they hid for about a half hour before slipping out through the stockroom in the back of the store.
The shoppers who hid themselves in the supermarket's cold store repeated a survival technique used when an Islamist attacker took hostages three years ago at a Jewish deli in Paris.
In January 21015, shopworker Lassana Bathily ushered panicked shoppers into a cold storage room at the Parisian kosher deli when an Islamist militant killed four Jewish hostages. The shoppers waited out the attack in the room.