Armed police have killed a suspect who shot dead three people in a series of attacks in southern France.
The heavily armed gunman hijacked a car and then took hostages at a supermarket in the town of Trèbes.
The man, named as 26-year-old Redouane Lakdim, said he was fighting on behalf of the Islamic State group.
He is believed to have killed and wounded his victims in three separate incidents which began in Carcassonne, 15 minutes' drive from Trèbes.
Later, President Emmanuel Macron said 16 people had been injured in the attack.
Among them is a gendarme who swapped places with a hostage. Mr Macron said the man, who has been hailed for his heroism, was fighting for his life in hospital.
He was shot several times, Paris prosecutor Francois Molins told reporters. One person has been arrested in connection with the shootings, he added.
The suspect is said to have been demanding the release of Salah Abdeslam, the most important surviving suspect in the 13 November 2015 attacks in Paris, which killed 130 people.
Mr Macron called the attack an act of "Islamist terrorism".
How did events unfold?
The attacker began his spree of attacks on Friday morning in Carcassonne, where he first hijacked a car, killing one passenger - whose body was later found hidden in a bush - and injuring the driver.
He then shot and wounded a policeman who was jogging with colleagues.
The suspect is then believed to have driven a few kilometres to the small town of Trèbes, where he charged into the Super-U supermarket, shouting, "I am a soldier of Daesh [Islamic State]!" and took hostages.
Carole, who was shopping at the supermarket, said people hid in a cold room.
"A man shouted and fired several times. I saw a cold room door, I asked people to come and take shelter," she told France info radio.
"There were 10 of us, and we stayed an hour. There were more gunshots and we went out the emergency back door."
Interior Minister Gérard Collomb told reporters that police officers managed to get some people out, but that the gunman held one woman back as a human shield.
It was at this point, he said, that the 45-year-old gendarme volunteered to swap himself for her - and left his mobile phone on a table with an open line so police could monitor the situation,
When police heard gunshots, an elite Swat team stormed the supermarket. The gunman was killed but the gendarme was seriously injured, and another officer was also hurt.
Mr Collomb hailed the "heroism and courage" of the gendarme, a lieutenant-colonel.
What do we know about the suspect?
Redouane Lakdim, reportedly from a Moroccan background, was known to French intelligence services, said Mr Collomb.
"He was known for petty crimes," including small-time drug-dealing, he said. "We had monitored him and thought there was no radicalisation," he said.
Has very active on Salafist social networks and incarcerated in Carcassonne in 2016, reports Le Parisien. Salafism is a hardline offshoot of Sunni Islam.
He is also suspected of making a trip to Syria, though that is unconfirmed, Le Parisien adds.
Lakdim lived in an apartment in Carcassonne with his parents and several sisters - one of whom a neighbour saw him taking to school on Friday morning.
That apartment has now reportedly been raided by police.
What has the reaction been?
In a statement released online, Islamic State claimed the attacker was "a soldier of the Islamic State" - a claim President Macron said the security services were studying.
Mr Macron was at an EU summit in Brussels when the attack took place but said he would return to oversee the response.
France has been hit with several deadly jihadist attacks since 2015 and has been on high alert since. A state of emergency put in place after the 2015 attacks in Paris was lifted in October.
In February, Salah Abdeslam went on trial in Belgium over a shootout in Brussels that led to his capture months after the Paris attacks. He is not expected to go on trial in France until 2020 at the earliest.
Major terror attacks in France
- 1 Oct 2017 - Two women stabbed to death at Marseille railway station; attack claimed by IS
- 26 Jul 2016 - Two attackers slit priest's throat at his church in Normandy; shot dead by police
- 14 Jul 2016 - Huge lorry mows down crowd on Nice beachfront, killing 86. IS claims attack by Tunisian-born driver, later shot dead by police
- 13 Jun 2016 - Police officer and his partner stabbed to death at home in Magnanville, west of Paris, by a jihadist declaring allegiance to IS - police later kill him
- 13 Nov 2015 - IS jihadists attack Paris, targeting the national stadium, cafes and Bataclan concert hall, leaving 130 dead
- 7-9 Jan 2015 - Two Islamist gunmen storm the offices of satirical magazine Charlie Hebdo, killing 17 people. Another Islamist militant kills a policewoman the next day and takes hostages at a Jewish supermarket in Paris. Four hostages are killed before police shoot the gunman dead. The other two gunmen are cornered and killed by police in a siege.