TREBES, France -- A French police officer who offered himself up to an Islamic extremist gunman in exchange for a hostage died of his injuries, raising the death toll in the attack to four. The officer was honored Saturday as a national hero of "exceptional courage and selflessness."

Col. Arnaud Beltrame, 44, was among the first officers to respond to the attack on the supermarket in the south of France on Friday.

Beltrame, who first took his place among the elite police special forces in 2003 and served in Iraq in 2005, had organized a training session in the Aude region in December for just such a hostage situation. At the time, he armed his officers with paintball guns, according to Depeche du Midi, the local newspaper.

Get Breaking News Delivered to Your Inbox

"We want to be as close to real conditions as possible," he said then.

But when he went inside the supermarket on Friday, he had given up his own weapon and volunteered himself in exchange for a female hostage.

In this image dated March 2013 and provided by regional newspaper Ouest France, Arnaud Beltrame poses for a photo in Avranches, western France. Ouest France via AP

Unbeknownst to the Morocco-born captor, he left his cellphone on so police outside could hear what was happening in the store. They stormed the building when they heard gunshots, officials said. Beltrame was fatally wounded.

His death raises the toll to four. The gunman was also killed, and 15 people were injured in the attack.

Announcing the police officer's death on Twitter, Interior Minister Gérard Collomb said: "He died for his country."

"France will never forget his heroism, his bravery, his sacrifice," Collomb said, the BBC reports.

"Arnaud Beltrame died in the service of the nation to which he had already given so much," President Emmanuel Macron said in a statement. "In giving his life to end the deadly plan of a jihadi terrorist, he fell as a hero."

Beltrame graduated in 1999 from France's leading military academy in Saint Cyr, according to the BBC. He joined the elite police special forces in 2003 and deployed to Iraq in 2005, according to a statement. He served as a member of the presidential guard and in 2012 earned one of France's highest honors, the Order of Merit. He was married with no children.

Beltrame's brother, Cedric Beltrame, told RTL radio Saturday his sibling died "a hero." He added that his brother "was well aware he had almost no chance. He was very aware of what he was doing."

People were placing flowers in front of the Gendarmerie headquarters in Carcassone to pay tribute to Col. Beltrame.

Macron has said investigators will focus on establishing how the gunman, identified by prosecutors as Morocco-born Redouane Lakdim, got his weapon and how he became radicalized.

On Friday night, authorities searched a car and the apartment complex in central Carcassonne where Lakdim was believed to live.

Two people were detained over alleged links with a terrorist enterprise, one woman close to Lakdim and one friend of his, a 17-year-old male, Paris prosecutor office said.

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 said there was "no warning sign" that Lakdim would carry out an attack.

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 wasn't 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!" -- the Arabic phrase for 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."

The manager of the supermarket said she felt "helpless." The woman, who would identify herself only by her first name, Samia, said that she was in her office when she heard the shots.

"How am I? I am devastated," she said "What we went through yesterday was a tragedy. What else would you have me say? You feel utterly helpless ."

She said she helped evacuate as many people as possible.

"It was terrifying," she 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 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.

France has been on high alert since a series of extremist attacks in 2015 and 2016 that killed more than 200 people. One of those attacks, against a kosher supermarket in Paris, seemed to foreshadow this week's deadly assault in the south.