The operation to free the secret agent, with the alias of Denis Allex, was launched by France's elite DGSE secret service, Defence Minister Jean-Yves Le Drian said in a statement.
"All indications are (that Allex was) killed by his captors," Le Drian said, adding that one French pilot was killed and another soldier was missing. He had earlier spoken of two dead troops.
But the Shebab extremists denied Le Drian's assertion that they had killed the hostage, adding that they would decide his fate in two days and issuing a stern warning to Paris.
"In the end, it will be the French citizens who will inevitably taste the bitter consequences of their government's devil-may-care attitude towards hostages," a Shebab statement said.
Le Drian said the raid in Bulomarer, some 110 kilometres (70 miles) south of the Somali capital Mogadishu, was sparked by the "intransigence of the terrorists who have refused to negotiate for three and a half years and were holding Denis Allex in inhuman conditions."
French President François Hollande expressed his a great distress over the deaths and extended his condolences to the families of victims.
Sheikh Mohamed Abdallah, a local Shebab military commander, told AFP: "Mujahedeen fighters defeated the so-called commandos of the French government who tried to rescue a hostage, and they (the commandos) left the bodies of several of their own at the site of the attack."
Abdallah is the commander of Bulomarer.
The Shebab statement said the French carried away "several" of their dead.
"The helicopters attacked a house ... upon the assumption that Denis Allex was being held at that location, but owing to a fatal intelligence blunder, the rescue mission turned disastrously wrong.
"Several French soldiers were killed in the battle and many more were injured before they fled from the scene of battle, leaving behind some military paraphernalia and even one of their comrades on the ground.
"The injured French soldier is now in the custody of the mujahedeen and Allex still remains safe and far from the location of the battle," it said.
A Bulomarer resident, Idris Youssouf, told AFP: "We don't know exactly what happened because the attack took place at night, but this morning we saw several corpses including that of a white man.
"Three civilians were also killed in the gunfight," he said.
Allex was kidnapped in Somalia in July 2009 along with a colleague who was freed the following month.
Four military helicopters were used in the raid in Shebab-controlled Bulomarer, witnesses said.
The Al-Qaeda linked Shebab lost their main strongholds in the south and centre of the country following an offensive launched in mid-2011 by an African Union force, but they still control some rural areas.
Allex is among nine French hostages in Africa of whom at least six are held by Al-Qaeda in the Islamic Maghreb (AQIM).
He appeared in a video in June 2010 appealing to Paris to drop its support for the Somali government.
He last appeared in another video in October looking gaunt and calling on Hollande to work for his release.
Somalia has not had an effective central government since 1991. However, a new administration took office last year, ending eight years of transitional rule by a corruption-riddled government.