He killed three people and wounded others before being shot to death when French police stormed the market, authorities said.
Among the seriously wounded was a French policeman who offered himself in a hostage swap and gave police details about what was going on inside the supermarket.
French President Emmanuel Macron said it appeared to be a terrorist attack, the first to hit France since he became leader in May.
The Islamic State group claimed that the attacker – a 26-year-old known to French police for petty crime and drug dealing – was one of its “soldiers”.
The hours-long drama began when the attacker hijacked a car near the medieval city of Carcassonne yesterday morning, killing one person in the car and injuring the other, according to French interior minister Gerard Collomb.
The attacker, identified as Redouane 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 shot in the shoulder, but the injury was not serious, Lefebvre said.
Lakdim then went to a Super U supermarket in the nearby small town of Trebes, 60 miles south-east of Toulouse, shooting and killing two people in the market and taking an unknown number of people hostage.
Special police units converged on the scene while authorities blocked roads and urged residents to stay away. Police were able to evacuate some shoppers at the supermarket.
One officer offered himself up in a hostage swap and was seriously injured, Collomb said. The officer managed to leave his cellphone switched on after the swap, establishing contact with officers outside the supermarket. Collomb did not say how the police officer was wounded.
Through that phone, police heard gunshots inside the building and decided that elite forces had to storm the market, killing Lakdim, Collomb said. He said two other officers were wounded during the assault.
“He acted alone, there was no one else but him,” Collomb said, speaking from Trebes.
During the stand-off, Lakdim requested the release of Salah Abdeslam, the sole surviving assailant of the 2015, attacks in Paris that left 130 people dead.
The interior minister said Lakdim was a petty criminal and small-time drug dealer who had been under police surveillance, but it was not clear to authorities that he was a committed radical.
“It was more of a petty criminal who at a certain moment decided to act,” he said.
The IS-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 IS militants in Syria and Iraq since 2014. France has been repeatedly targeted because of its participation in the airstrikes.
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 that killed more than 200 people.
While France hasn’t seen an attack in several months “the threat remains high,” Macron said, describing ongoing risks from “several individuals who radicalized themselves.”
The attack Friday occurred in a normally quiet part of France, where the main tourist attraction is the treasured old city of Carcassonne, its medieval walls and its summertime festivals.
The attack poses a new challenge to Macron’s leadership as he faces nationwide strikes and criticism of his reforms, which include a tough new counterterrorism law that gives police extra powers to conduct searches and hold people under house arrest.
Macron rushed back from an EU summit in Brussels to the crisis center in Paris that was overseeing the investigation into the attack.
Standing next to Macron in Brussels, German Chancellor Angela Merkel expressed her sympathy with those affected by the hostage-taking.
“When it comes to terrorist threats, we stand by France,” she said.