A gunman killed three people in southwestern France on Friday as he held up a car, fired on police and seized hostages in a supermarket, screaming "Allahu Akbar" before security forces stormed the building and killed him, authorities said.
The attacker was identified by authorities as Redouane Lakdim, 25, from the city of Carcassonne.
The Islamic State group claimed responsibility for the attack. French President Emmanuel Macron said security services were checking that claim.
"I want to tell the nation tonight of my absolute determination in leading this fight," said Macron, who returned to Paris from Brussels to chair a crisis meeting with ministers and security officials.
Two people were killed when Lakdim attacked the supermarket in the nearby small town of Trebes.
Witnesses said about 20 people in the supermarket found refuge in its cold storage room.
A lieutenant-colonel of the gendarmes who swapped himself in exchange for one of the hostages was fighting for his life in hospital, Macron said.
- Tracing the roots of European terror: What led a young Belgian to become an ISIS terrorist
- Black, Muslim and unwelcome: Is Europe facing a Somali 'jihad generation' crisis?
- ISIS-linked gunman shot dead by French police after taking hostages, killing three
Moroccan-born Lakdim was known to authorities for petty crimes, but had been under surveillance by security services in 2016-2017 for links to the radical Salafist movement, said Paris prosecutor Francois Molins, who is leading the investigation.
"The monitoring ... did not reveal any apparent signs that could lead (us) to foresee he would act," Molins said.
He said one woman connected to Lakdim had been arrested.
Interior Minister Gerard Collomb told reporters at the scene that he believed Lakdim had acted alone.
"Every day we detect facts and foil new attacks. Alas, this one struck without us being able to counter it," Collomb said.
Lakdim first killed one person with a bullet in the head while stealing a car in Carcassonne, a walled city with a medieval citadel that is one of France's top tourist attractions.
He pulled up in the car to four police officers who were jogging in the city and opened fire, hitting one in the shoulder, then sped off to Trebes, about 8 km (5 miles) to the east, where he took the hostages in the supermarket.
"The perpetrator entered the store shouting 'Allahu Akbar' and indicated that he was an Islamic State soldier who was ready to die for Syria, seeking the release of brothers, before shooting at a client and a store employee who died on the spot," Molins said.
Police were carrying out searches at Lakdim's family home.
One supermarket worker said some shoppers had escaped from the building after the gunman burst in.
"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, who has been employed at the supermarket since November.
Collomb said the gunman had demanded the release of Salah Abdeslam - the prime surviving suspect in Islamic State suicide bombing and mass shooting attacks on a sports stadium, concert hall and restaurants that killed 130 people in Paris in 2015.
Abdeslam, a French citizen born and raised in Brussels, went on trial in Belgium last month. He is accused of "attempted murder in a terrorist context" over a Brussels shootout in March 2016, four months after he fled Paris on the night of the carnage during which his brother was among the suicide bombers.
'The threat is everywhere'
France is part of a U.S.-led coalition fighting against Islamic State in Syria and Iraq and also has thousands of soldiers in West Africa fighting al Qaeda-linked militants.
In February, Collomb said French security forces had foiled two planned attacks so far this year as Islamic State militants set their sights on domestic targets in response to the group's military setbacks in Iraq and Syria.
"This is a small, quiet town. Unfortunately the threat is everywhere," Collomb told reporters in Trebes.
Carcassonne, a UNESCO heritage site, lies in the Languedoc region, known for its wine and picturesque countryside but also one of the poorest areas in France, with unemployment about 3 percentage points above the national average.
Nearby Beziers is one of the biggest cities controlled by the far-right, while the smaller town of Lunel further east became a breeding ground for many French jihadists who travelled to Syria to fight.
Almost six years ago to the day, Islamist gunman Mohammed Merah killed seven people in the Toulouse region, about 90 km from Carcassonne. He was killed by security forces after a more than 30-hour stand-off.
More than 240 people have been killed in France in attacks since 2015 by assailants who pledged allegiance to Islamic State or were inspired by the group.
The last lethal Islamist attack in France was in October 2017 when a Tunisian-born man stabbed two young women to death in Marseille before he was shot dead by soldiers. Islamic State also claimed responsibility for that attack.