A British security contractor working in Somalia was injured when suspected terrorists attacked him in a prison cell, slashing his throat with a razor blade, according to reports.

Antony Cox was set upon by suspected Islamist militants being held alongside him in Mogadishu Central Prison, local authorities told the BBC.

Reports said the 48-year-old had been arrested earlier this month at Mogadishu airport over possession of CS gas canisters in his suitcase.

Mr Cox was working for US private security firm Bancroft Global Development, the prison’s deputy governor, Abdikarim Ali Afrah, told the broadcaster. But the firm told The Independent he was not an employee.

He said guards intervened following a tip-off about the impending assault.

“As one of the suspects was about to cut his [Mr Cox’s] neck, we managed to stop him. He sustained a very minor cut. He is doing well,” he added.

Mr Cox’s injuries are not thought to be life-threatening.

The affiliations of the men who attacked the contractor was not clear; the BBC reported one was suspected to be a member of the Somali group al-Shabaab and the other from Isis, while The Times reported both were thought to be Isis members.

Support free-thinking journalism and attend Independent events

According to a profile on LinkedIn, Mr Cox previously worked in Somalia as a deputy security manager for SKA Group and is a former member of the French Foreign Legion.