The French police officer who offered himself up in a hostage swap Friday after an armed man yelling “Allahu akbar” went on a rampage in southern France has died, a report said early Saturday.

French President Emmanuel Macron said Lt. Col. Arnaud Beltrame, 44, died after being seriously injured in the attack. Macron said Beltrame "fell as a hero" and "showed exceptional courage."

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

Interior Minister Gerard Collomb wrote in a tweet early Saturday that Beltrame had "died for his country."

The officer had offered himself up unarmed to the 25-year-old attacker in exchange for a female hostage. 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, killing the gunman.

Beltrame was grievously injured, and his death raised the toll from the attack to four. Some 15 other people were injured in the attack.

"He gave his life for strangers. He must have known that he didn't really have a chance. If that doesn't make him a hero, I don't know what would," Beltrame's brother, Cedric, said in a radio interview Saturday.

Beltrame joined the elite police special forces in 2003 and served in Iraq in 2005. People were placing flowers in front of the Gendarmerie headquarters in Carcassone to pay tribute to the fallen officer.

The Islamic State group claimed responsibility for the attack, the deadliest since Macron became president last May. Macron said investigators will focus on establishing how the gunman, identified as Morocco-born Redouane Lakdim, got his weapon and how he became radicalized.

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.

The series of events appeared to begin when Lakdim hijacked a car near the medieval city of Carcassonne Friday morning, killing one person in the vehicle and injuring another.

Yves Lefebvre, the secretary general of SGP Police-FO police union, said Lakdim then fired at least six shots at a group of police officers who were returning from a jog nearby. He said the officers were wearing athletic clothes with police insignias.

One officer was shot in a shoulder, but the injury was considered not life threatening.

Afterward, Lakdim went to the Super U supermarket in Trebes, 60 miles southeast of Toulouse, where he opened fire and killed two people. He took an unknown number of hostages. French counterterrorism prosecutor Francois Molins confirmed that Lakdim shouted "Allahu akbar" - the Arabic phrase for God is great - as he entered the supermarket and claimed to be a "soldier of the Islamic State." There were about 50 people inside the market when the suspect entered, the prosecutor said.

Molins added that an unidentified woman who was close to the suspect and shared a life with him was taken into custody on Friday.

During the standoff, Lakdim demanded the release of Salam Abdeslam, the lone survivor of an ISIS terror cell behind the deadly 2015 attacks in Paris that killed 130 people, officials said.

Counterterrorism investigators took over the probe into Friday's rampage. France has been on high alert since a string of Islamic extremist attacks in 2015 and 2016 left more than 200 people dead.

Fox News' Elizabeth Zwirz and the Associated Press contributed to this report.