French prosecutors describe the incident in southwestern France as terrorism related
A gunman claiming allegiance to the Islamic State (IS) group killed three people in a shooting spree and supermarket hostage siege in southwest France on Friday before anti-terror police shot him dead.
Five people were also shot and wounded in France's first major attack since October, including a policeman who offered to take the place of hostages being held at the supermarket.
"Our country has suffered an Islamist terrorist attack," President Emmanuel Macron said in a televised address following the rampage in the medieval town of Carcassonne and nearby Trebes.
The shootings come as France remains on high alert following a string of deadly attacks that have killed more than 240 people since 2015.
Friday's attacker was identified by authorities as Redouane Lakdim, 25, from the city of Carcassonne.
"He had been on a watchlist for his radicalisation and links to the Salafist movement," Molins told reporters in Carcassonne, adding that Lakdim had been tracked for his online contacts with extremists.
Security sources said Lakdim was born in Taza in northern Morocco and held French nationality. His partner, who lived with him in Carcassonne, has been detained, Molins said.
Lakdim started his rampage in Carcassonne at around 10:30 am (0930 GMT), hijacking a car and shooting the two people inside, Molins said. The passenger was killed, and the driver remains in a critical condition.
Lakdim then shot and wounded a police officer who was out jogging with colleagues before driving nearby where he burst into a supermarket.
"I was five metres away from him," the supermarket's security guard said, speaking on condition of anonymity.
"He shot at me twice." Luckily for the security guard, "he shot badly."
About 50 people were in the supermarket at the time, and though some people managed to escape, several remained inside.
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.
Senior officer Arnaud Beltrame, 45, offered to take their place while his colleagues negotiated with Lakdim, Molins said.
When special forces heard shots they stormed the store, killing the gunman and recovering Beltrame, who had been "seriously wounded".
Macron led tributes to the police officer, who has been hailed as a hero.
"He saved lives and honoured his colleagues and his country," Macron said.
"He is currently fighting for his life and all our thoughts go out to him and his family," he added.
A Portuguese national initially reported as dead due to "communication errors" was in fact seriously wounded and taken to hospital in Carcassonne, the government in Lisbon said.
The fact that Lakdim had been monitored as a potential militant will raise difficult questions for Macron's government as to how he slipped through the net.
"We had monitored him and did not think he had been radicalised," Interior Minister Gerard Collomb said of Lakdim after flying to the scene.
"He was already under surveillance when he suddenly decided to act."
In Paris, the Eiffel Tower dimmed its lights at midnight in a mark of respect for the victims and a minute's silence was held at the Stade de France before a football match between France and Colombia.
Friday's violence took place in a part of France still scarred by a killing spree in 2012 in the city of Toulouse and nearby Montauban where another jihadist, Mohamed Merah, shot dead seven people including three Jewish schoolchildren.
That assault marked the first of several big attacks in France since 2015, including the massacre at the satirical newspaper Charlie Hebdo, the November 2015 attacks that killed 130 in Paris, and a summer 2016 truck attack during Bastille Day festivities in Nice.
A state of emergency put in place just after the 2015 Paris attacks was lifted last October when Macron's centrist government passed a new law boosting the powers of security forces.
Soldiers continue to patrol major tourist sites around France and transport hubs under an anti-terror mission.
"We are in a small and calm town, but sadly the threat is everywhere," Collomb said.