French spy Denis Allex was killed by his Somalian captors during a botched rescue attempt (Picture: AFP/Getty)

A French spy held hostage in Somalia for three years has died along with one commando and 17 Islamists in a botched rescue attempt.

The French authorities confirmed the deaths, although the man’s extremist kidnappers said the hostage was alive and that a French soldier had been captured as well during the overnight raid in the town of Bulomarer.

The militant Islamist group al-Shabab, which had held DGSE spy service agent code-named Denis Allex since 2009, said today he is alive and remains in their custody, along with a new captive – a French commando wounded in the failed rescue.

French defence minister Jean-Yves Le Drian said one French soldier was missing and one was dead, while 17 Islamists and the hostage were killed in the fighting.

‘It was an extremely dangerous mission,’ Mr Le Drian said.

Mr Allex was kidnapped from a hotel in Mogadishu while in Somalia to train government forces, which are fighting Islamist militiamen.

An al-Shabab official confirmed that fighting began after helicopters dropped off soldiers.

‘We had Mujahideen fighters already deployed there who fought back the French soldiers. We killed some of their soldiers but only one dead soldier in a French military uniform is in our hands now,’ he said.

Onlookers at Ngolonina market in the Malian capital of Bamako, where the French have sent troops (Picture: Reuters)

It comes after a separate French military intervention in Mali to help the country against al-Qaida-linked militants.

A Mali army official said Islamist militants have been driven out of Konna, a city the extremists captured this week, but that it is not yet under government control.

A French special forces helicopter pilot was killed in the fighting, which involved hundreds of French troops and overnight airstrikes on three rebel targets after a plea from the Mali president.

The al-Qaida-linked Islamist group Ansar Dine in Mali (Picture: AP)

French president Francois Hollande said the ‘terrorist groups, drug traffickers and extremists’ in northern Mali ‘show a brutality that threatens us all’. He vowed that the operation would last ‘as long as necessary’.

The United Nations Security Council has condemned the capture of Konna and urged UN member states to help Mali and ‘to reduce the threat posed by terrorist organisations and associated groups’.

The West African regional bloc ECOWAS later authorised the immediate deployment of troops to Mali to help oust the Islamists, but did not confirm which countries were providing troops or how many were going.