* French president says incident appears to be terrorist attack
* 240 people killed in militant attacks in France since 2015
Three people were killed in southwestern France on Friday when a gunman held up a car, opened fire on police and then took hostages in a supermarket, screaming "Allahu Akbar".
Police later stormed the supermarket in the small town of Trebes and Interior Minister Gerard Collomb said on Twitter that the attacker had been killed.
A source at the Interior Ministry said two had died at the hostage-taking in Trebes. "It is a provisional assessment as it could unfortunately get worse. Three people are wounded, including one of them seriously," the source said.
Later, a police union official said the attacker had also killed one person with a bullet in the head in the nearby historic town of Carcassonne before the hostage-taking.
French President Emmanuel Macron said the incident appeared to be a terrorist attack and security forces were securing the area.
Eric Menassi, the mayor of Trebes, told BFM TV that the hostage-taker was now alone with one police officer in the supermarket and all other hostages were free.
The station reported that the hostage-taker has claimed allegiance to Islamic State and that he has demanded the release of Salah Abdeslam - the prime surviving suspect in the Islamic State attacks that killed 130 people in Paris in 2015.
A 45-year-old lieutenant-colonel swapped himself in exchange for one of the hostages, a source close to the investigation said later, confirming information first published by Le Figaro
More than 240 people have been killed in France in attacks since 2015 by assailants who pledged allegiance to, or were inspired by, Islamic State.
First the gunman held up a car, killing one person and wounding another. Then he fired one police officers in Carcassone, wounding an officer in the shoulder before heading to Trebes about 8 km to the east, where two more died in the Super-U supermarket.
Menassi also told LCI TV that the man had entered the shop in Trebes screaming "Allahu Akbar, I'll kill you all".
Carole, who was shopping at the supermarket, described how people had taken refuge in a cold room.
"A man shouted and fired several times. I saw a cold room door, I asked people to come and take shelter," she told Franceinfo radio. "We were ten, and we stayed an hour. There were more gunshots and we went out the back door."
French investigators believe they have identified the hostage-taker. The man is known to the intelligence services and flagged in a database of radicalised Islamist militants, Franceinfo reported.
Police in helmets and body armour took up positions around the Super-U supermarket.
The Paris prosecutor's office said counter-terrorism prosecutors were investigating the incident but did not comment on the possible Islamic State allegiance.
Earlier, the Interior Ministry had said security forces were carrying out an operation at a supermarket in southern France. Interior Minister Gerard Collomb was on his way.
The UNSA police union also said on Twitter a police operation was underway after an individual had earlier shot at four officers in the Carcassone region, wounding one of them.