(CNN) -- Three people were killed and five others wounded Friday in southern France after a gunman stole a car, fired at police officers and took hostages in a supermarket in what authorities are treating as a terror attack.
One person died in the carjacking, and two others were killed at the market, the French Interior Ministry said.
Police shot dead the gunman, French media reported, after a four-hour standoff at the Super U supermarket in the town of Trèbes. The Interior Ministry identified Redouane Lakdim, 26, as the gunman. He was known to authorities for minor crimes, including drug offenses, Interior Minister Gérard Collomb said.
An investigation has been opened into murder and attempted murder "in connection with a terrorist in Trèbes," the French prosecutor's office told CNN.
Police have taken into custody a woman who was "very close" to Lakdim and "shared his life," prosecutor François Molins told reporters at a news conference in Carcassonne.
"Our country has suffered an Islamist terrorist attack," President Emmanuel Macron told reporters. "We've paid the price of the danger of the terrorist threat in blood for several years.
"I want to state my absolute determination to the nation to lead this fight."
The ISIS-affiliated Amaq News Agency said that the gunman was a "soldier" of the militant group and that he had responded to its call to attack coalition countries, a reference to the U.S.-led coalition fighting ISIS in Syria and Iraq. Amaq offered no evidence ISIS had any contact with the attacker.
"This attack has been claimed by ISIS, and it is currently being analyzed," Macron said.
A local prosecutor said the attack appeared to be "ISIS-inspired," CNN affiliate BFM TV reported. Witnesses said the man shouted, "I am a Daesh soldier," using another name for ISIS.
CNN could not independently confirm the gunman made the demand. Abdeslam is on trial in Belgium.
France has faced a string of terror attacks in recent years, including the Paris attacks and other smaller-scale assaults. The country remained under a state of emergency for about two years after the Paris attacks. It was lifted late last year.
How the rampage began
The violence unfolded when the attacker stole a car, killing one person in the vehicle and gravely wounding another, said Collomb, the interior minister.
The gunman then shot at four National Police officers who were jogging in Carcassonne. The driver tried to run the officers down. One of them was wounded, but he is not in serious condition.
The gunman proceeded to the Super U market. He entered the market, firing his weapon and killing two people. He took several others hostage.
Police found the car, and SWAT teams surrounded the market.
Collomb said a National Police lieutenant colonel shot the gunman after offering himself for at least one of the hostages. The officer was also seriously wounded. The order of the shots was unclear, Collomb said Police then raided the store after hearing gunshots.
Two others were wounded at the market, an Interior Ministry spokesman said.
"People were absolutely calm before and never thought that there could be an attack in a town like this," Collomb told reporters, adding that the risk of terrorism in France remained "very high."
A supermarket employee who fled as shots were fired told BFM that he and about 50 others had been on lockdown in a car park.
Madeline Fuhrman, a witness, said that Trèbes had gone quiet after the attack.
"It's totally deserted now. Absolutely every shop is closed. There's not a soul in sight," she said.
Macron, who was in Belgium for a summit of European Union leaders, returned to France and spoke to reporters after a crisis meeting at the Interior Ministry.
The French leader hailed law enforcement's response.
"The forces of order intervened with remarkable speed, both to contain the individual who hid away with his hostages, to help one of the victims who was still alive who he had left in the surrounding area," Macron said.
He singled out the officer who volunteered to be traded for a hostage and saluted his bravery.
"He has saved lives, and done his role and his country proud. He is currently fighting for his life, and all our thoughts are with him and his family," Macron said.
Macron said the investigation should answer several questions -- when and how the gunman was radicalized and where he got a weapon.
He said French soldiers overseas risk their lives "to reduce this threat."
CORRECTION: This story has been updated to correct the spelling of the interior minister's name.
™ & © 2018 Cable News Network, Inc., a Time Warner Company. All rights reserved.
for more features.