TREBES, France (AP) - A gun-wielding extremist went on a rampage Friday in a quiet corner of southern France, killing three people as he hijacked a car, opened fire on police and took hostages in a supermarket, where panicked shoppers hid in a meat locker or ran through the aisles.
After an hourslong standoff, the 25-year-old attacker was slain as elite police forces stormed the market. They were aided by a heroic police officer who had offered himself up in a hostage swap and suffered life-threatening wounds as a result - one of 16 people injured in the day's violence.
The Islamic State group claimed responsibility for the attack near Carcassonne, a medieval city beloved by tourists, and the town of Trebes. It was the deadliest attack in France since Emmanuel Macron became president last May.
The officer who volunteered to take the place a female hostage was identified as Col. Arnaud Beltrame. He managed to surreptitiously leave his cellphone on so that police outside could hear what was going on inside the supermarket. Officials said once they heard shots inside the market they decided to storm it.
A police official who was not authorized to be publicly identified confirmed the officer's identity to The Associated Press.
"He saved lives," Macron said.
Macron said investigators will focus on establishing how the gunman, identified by prosecutors as Moroccan-born Redouane Lakdim, got his weapon, and how he became radicalized.
On Friday night, authorities searched a vehicle and a building in central Carcassonne.
Lakdim was known to police for petty crime and drug-dealing. But he was also under surveillance and since 2014 was on the so-called "Fiche S" list, a government register of individuals suspected of being radicalized but who have yet to perform acts of terrorism.
Despite this, Paris prosecutor Francois Molins there was "no warning sign" that Lakdim would carry out an extremist attack.
A woman close to Lakdim was taken into custody over alleged links with a terrorist enterprise, Molins said. He did not identify her.
The four-hour drama began at 10:13 a.m. when Lakdim hijacked a car near Carcassonne, killing one person in the car and wounding the other, the prosecutor said.
Lakdim then fired six shots at police officers who were on their way back from jogging near Carcassonne, said Yves Lefebvre, secretary general of SGP Police-FO police union. The police were wearing athletic clothes with police insignia. One officer was hit in the shoulder, but the injury was not serious, Lefebvre said.
Lakdim then went to a Super U supermarket in nearby Trebes, 60 miles (100 kilometers) southeast of Toulouse, shooting and killing two people in the market and taking an unknown number of hostages. Special police units converged on the scene while authorities blocked roads and urged residents to stay away.
He shouted "Allahu akbar! (God is great)" and said he was a "soldier of the Islamic State" as he entered the Super U, where about 50 people were inside, Molins said.
"We heard an explosion - well, several explosions," shopper Christian Guibbert told reporters. "I went to see what was happening and I saw a man lying on the floor and another person, very agitated, who had a gun in one hand and a knife in the other."
Guibbert said he led his wife and sister-in-law and nearby customers into the meat locker. Then he went back to see where the assailant was and called police to describe the situation.
"At that moment, he (the gunman) ran after me. Of course I left, I lost him and when I turned around he wasn't there anymore. I took an emergency door and saw the police arrive," Guibbert said.
Another witness, an employee of the supermarket's butcher department identified only by his first name, Jacky, told Europe 1 radio he "heard people shouting and a big 'boom.'"
"It was a gunshot," he said. "Then a second gunshot. After that, my colleagues came toward me saying: 'Come on Jacky, we need to leave! There's someone who's firing shots, he's shouting "Allahu akbar," and he's shot people and he's shooting at everything.'"
He said they left using an emergency exit behind the butcher's stall and they ran across the courtyard.
"We also helped people get out," he said.
During the standoff, Lakdim requested the release of Salah Abdeslam, the sole surviving assailant of the Nov. 13, 2015, attacks in Paris that left 130 people dead. The interior minister suggested, however, that Abdeslam's release wasn't a key motive for the attack.
The IS-linked Aamaq news agency said the attacker was responding to the group's calls to target countries in the U.S.-led coalition carrying out airstrikes against IS militants in Syria and Iraq since 2014. France has been repeatedly targeted because of its participation.
Both Interior Minister Gerard Collomb and Molins praised Beltrame, who Molins said "at the risk of his life took the choice to take the place of the hostages."
The gunman shot Beltrame several times after threatening to blow up the supermarket if police entered, Molins added.
BFM television said Beltrame recently took part in a training exercise simulating a terrorist attack.
As the supermarket standoff reached a crescendo about 2:20 p.m., police heard gunshots inside the building and decided that elite forces had to storm it. Lakdim was killed and two other officers were wounded during the assault, Collomb said.
"He acted alone, there was no one else but him," he added.
Macron rushed back from an EU summit in Brussels to Paris, where counterterrorism investigators took over the investigation. France has been on high alert since a series of extremist attacks in 2015 and 2016 that killed more than 200 people.
While France hasn't had an attack in several months, "the threat remains high," Macron said, describing ongoing risks from "several individuals who radicalized themselves."
Macron pushed through a tough counterterrorism law last year that gives police extra powers to conduct searches and hold people under house arrest.
In Brussels, German Chancellor Angela Merkel appeared with Macron and said, "When it comes to terrorist threats, we stand by France."
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.