Receive the latest national-international updates in your inbox

Police cordons off the area of a raid at the suspect's residence involved in a shooting, in Carcassonne, southern France, Friday, March 23, 2018. A gun-wielding extremist unleashed bloodshed in a quiet corner of southern France on Friday, killing three people as he hijacked a car, opened fire on police and took hostages in a supermarket.

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 hours-long 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.

Photo credit: NBC

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."

"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.

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 ISIS-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 ISIS 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.

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."

At the national stadium outside Paris, 80,000 soccer fans and the national teams of France and Colombia observed a minute of silence Friday night to honor those killed in the attacks earlier in the day. Poignantly, the stadium itself was the site of bloodshed in the deadly Paris attacks in 2015.