The Islamist terror group al-Shabaab has said it has killed five people including a Briton whom it accused of spying.

Three of the men publicly shot dead in al-Shabaab-controlled territory in Somalia were accused of spying for the US government and one for Somali authorities.

The fifth is thought to have been Mohammed Ahmed Mohamed, 32, a terrorism suspect who gave British authorities the slip in 2013 by cutting off his electronic tag, putting on a burqa and walking out of a west London mosque.

The al-Qaida-linked group routinely shoots people accused of being spies, though often these are simply fighters caught on the wrong side of factional disputes.

Foreign fighters are particularly vulnerable to the charge. One was Omar Hammami, an American from Alabama known as the rapping jihadist, who was killed in 2013.

In December last year, five men were tied to poles and shot, accused of spying for the Kenyan and Ethiopian governments.

Al-Shabaab, one of the world’s deadliest terrorist organisations, used to control swathes of Somali territory including the capital, Mogadishu, but was pushed back into rural areas in 2011. The group wants to topple the western-backed government and peacekeeping force, and impose sharia law in Africa’s easternmost country.

Lately, it has been extorting starving people and recruiting hundreds of child soldiers and suicide bombers against their will as al-Shabaab grapples with a financial squeeze and lack of support. In recent months, the group has clashed with clan militias because of its efforts to conscript teenagers into its ranks.

At the time of his escape, Mohamed was subject to a terrorism prevention and investigation measures (Tpim) notice, a type of order brought in by the UK coalition government to monitor people thought to pose a risk, but where there is a lack of evidence.

A team of police, MI5 officers and Border Agency officials assembled by the Home Office could not catch him and he escaped the country.

Mohamed’s story was more complex than it first appeared, however: the British government faced accusations of complicity in torture and rendition in relation to his case. In 2011, he was detained in the self-declared state of Somaliland, allegedly subjected to beatings and mock executions, and flown to the UK against his will.

In 2014, Mohamed and another man won an appeal against control orders that had been imposed on them, and in 2015, an arrest warrant against him was dropped.

A Somali security official said it was believed that Mohamed may have joined Islamic State, which has been active in Somalia but has failed to recruit more than a handful of followers.

“He joined Islamic State and then tried to infiltrate al-Shabaab to recruit their members,” the official said. “They found out and killed him but said he was a spy for the west rather than say openly that he was working for a rival extremist organisation.”

Late on Wednesday an al-Shabab affiliated radio station also said that Mohamed was among the five men executed in Jilib on Tuesday. The network repeated the claim that he had spied for MI6.

A second security official confirmed that Mohamed had initially joined al-Shabaab when he came to Somalia four years ago before defecting to Isis.

A Somali intelligence officer Ahmed Yare said Mohamed was a dual Somali-British national.