A gendarme who exchanged himself for a hostage during the French supermarket siege has died, bringing the number of victims to four. Police shot dead the attacker after a series of attacks claimed by Islamic State in Carcassonne, southern France, that culminated in the three-hour hostage-taking.

The attacker, named as Radouane Lakdim, 25, was born in Morocco and lived in Carcassonne. He was known to police for petty crimes and drug-dealing. The state prosecutor François Molins said he had been under surveillance in 2016 and 2017 for his “radicalism and proximity to Salafist movements” but had showed no signs he was going to carry out an attack.

The shooting spree and supermarket hostage-taking on Friday, which also left 16 people injured – including two very seriously – was the first major suspected terrorist incident since President Emmanuel Macron lifted France’s two-year state of emergency last autumn and toughened anti-terror laws.

“Our country has suffered an Islamist terrorist attack,” Macron said in a televised address.

Isis claimed responsibility for the attacks, without providing evidence. Macron said French authorities were investigating the claim.

Questions will be asked as to how Lakdim was able to obtain a weapon and carry out attacks when he had been monitored by security services.

The interior minister, Gérard Collomb, said: “We had monitored him and did not think he had been radicalised.” He added: “He was already under surveillance when he suddenly decided to act.”

Just after 10am on Friday, Lakdim, stopped a white Opel Corsa car on the outskirts of Carcassonne, before shooting and killing the passenger and seriously injuring the driver.

The prosecutor said Lakdim then drove off in the car and appeared to wait outside a military barracks for soldiers. He then drove to a riot police squad barracks and shot at four officers 200 metres away who had been out jogging. He seriously wounded one of group, who suffered broken ribs and a punctured lung. A bullet struck near one officer’s heart.

Lakdim then drove to a Super U supermarket 8km away in Trèbes, a sleepy town of 5,000 people near Carcassonne. At about 11am, he walked into the shop shouting Allahu Akbar and claiming he was a soldier from Islamic State. Around 50 people were inside the building. Lakdim opened fire, killing one supermarket worker and one customer.

Christian Guibbert, a former police officer, was shopping when he heard several shots. He told BFM TV his first instinct was to hide his wife and other customers in a butcher’s fridge, before trying to escape through an emergency exit as the police arrived.

“I saw one person on the ground and a person who had a handgun in one hand and knife in the other and was shouting,” he said. “He was very agitated, I knew at once it was a terrorist. After 25 years in the police force, one knows these things. He shot several times in the air.”

Gendarmes attempting to evacuate the supermarket found Lakdim holding several hostages. A gendarme volunteered to take the hostages’ place. The gunman agreed to the swap, so the gendarme stayed with him while others were evacuated. That gendarme left his mobile phone line open on a table so security forces outside could hear what was going on inside. When security forces outside the store heard via the telephone that a shot was fired, they immediately stormed the supermarket and shot Lakdim dead.

Lt Col Arnaud Beltrame, the gendarme who had swapped places with the hostages, was found seriously injured. Early on Saturday morning, the French interior ministry said Beltrame had died from his injuries.

Collomb praised the officer’s heroism. Two other officers were injured by gunshots during the assault.

The interior ministry said Lakdim was acting alone in Friday’s attack. The state prosecutor said he had been on an intelligence watchlist since 2014. Lakdim had been convicted twice in 2011 and 2015 for petty crime, including drug offences. He had served one month in prison in 2016. The prosecutor said that during surveillance, security services had not seen signs that suggested Lakdim would commit an attack.

A woman who lived with him was being questioned by police.

Play Video

0:22

Police and ambulances at scene of French hostage situation – video

In October last year, Macron toughened anti-terror laws and lifted France’s two-year state of emergency which had been declared by former president François Hollande on the night of the Paris attacks that killed 130 people in November 2015.

Macron said the current terror threat in France was high but different to that two to three years ago when terrorist attacks were organised and ordered from within Syria and Iraq. Currently, the risk was from dangerous individuals in France who had radicalised themselves, he said.

French police have in recent years undertaken training to prepare for hostage-taking situations in supermarkets. In January 2015, after the terror attack on the satirical magazine Charlie Hebdo, a gunman, Amédy Coulibaly, held hostages at a kosher supermarket in eastern Paris, killing four people before police shot him dead.