Police in helmets and body armour took up positions around the supermarket before storming the premises and killing the gunman.
Eric Menassi, the mayor of Trebes, had earlier told BFM TV that the hostage-taker was alone with one police officer in the supermarket and all other hostages were free.
Mr Menassi also told LCI TV that the man had entered the shop screaming "Allahu Akbar, [God is greatest] I'll kill you all".
The station reported that the hostage-taker had claimed allegiance to Islamic State and that he has demanded the release of Salah Abdeslam — the prime surviving suspect in the Islamic State group attacks that killed 130 people in Paris in 2015.
French President Emmanuel Macron said all evidence suggested the hostage-taking and shootings were a terrorist attack.
Trebes supermarket shooting: Policeman who traded places with hostage dies in hospital
A policeman who swapped himself for a hostage held by a gunman during a deadly siege of a supermarket has died, the French Interior Minister confirmed. French officials hailed the bravery of Lieutenant Colonel Arnaud Beltrame, who was shot by attacker Redouane Lakdim after taking the place of a female hostage.
President Emmanuel Macron said in an address to the nation that Mr Beltrame had "saved lives".
"He fell as a hero, giving up his life to halt the murderous outfit of a jihadist terrorist," Mr Macron said.
Interior Minister Gerard Collomb said in a tweet that France would "never forget his heroism, his bravery, his sacrifice".
"With a heavy heart, I offer the support of the whole country to his family, his relatives and his companions of the Gendarmerie."
Mr Beltrame, a qualified parachutist who served for a spell in Iraq in 2005, took the place of a female hostage inside the supermarket. After making the swap, Mr Beltrame managed to secretly place his mobile phone, with an open line, on a table near himself and Lakdim.
"That way we were able to hear what was going on at a given moment," Interior Minister Gerard Collomb said.
Mr Molins said the gunman opened fire on Mr Beltrame, critically wounding him. The sound of that shooting prompted commando units to storm the building, when they killed the gunman. Mr Beltrame was raced to hospital but later died from his injuries. Two others died during the siege.
Mr Beltrame was in his mid-40s and also worked as part of the elite Republican Guard that protects the Elysee Palace offices and the president's residence in Paris.