MI5 faces claims that it has been complicit in torture as recently as this February, after a former British resident told how he was beaten by Egyptian security forces working closely with the UK.

Ahmed Diini, 25, alleges that he was questioned by a member of MI5 earlier this year while being tortured in an Egyptian prison. The claim challenges assurances given by Britain’s security and intelligence agencies last year that they no longer take part in operations where a suspect is being tortured or illegally detained by a foreign state.

In November, the head of MI5 told MPs that his officers would never participate in or condone torture.

Download the new Independent Premium app Sharing the full story, not just the headlines

Mr Diini, a grandson of the deposed Somalian dictator Mohamed Siad Barre, alleges that during his eight months’ imprisonment in Cairo he was shackled, hooded, repeatedly beaten, stripped and threatened that his wife would be raped. He also alleges he was threatened with electrocution and being whipped.

In a letter written from his prison cell and smuggled to his lawyer, Mr Diini says that during his detention and torture he was visited this year by a British man who, he believes, works for MI5. He says the man promised him his freedom if he agreed to work for the security service.

Mr Diini, who is a Dutch national but has two daughters living in the UK, refused the offer. He claims he was first targeted by MI5 when he lived in Birmingham between 2006 and 2011 and felt so worried that he complained to the media about his harassment.

In his letter to his lawyer, Andre Seebregts, in which he details his torture, he says: “I also want to inform you that on 17 February 2014 something very strange happened. I am now 100 per cent sure that the British secret service are part of this trouble, because I met one of their secret service agents who tried to induce me to work with them in exchange for my freedom. He visited me here in prison, a white Brit with a Londonish accent. He told me my Dutch government is not capable of doing anything for me.”

Mr Diini, who was arrested by the Egyptian security agency a few weeks after the military deposed the government of the Muslim Brotherhood last year, says that the British agent interviewed him for half an hour, ending the conversation by saying: “I will be back so make your decision wisely, it’s your freedom.” Two days after this meeting he claims his Egyptian guards made him watch a man tied against a wooden cross being whipped with a rubber hose.

CAGE, which campaigns against abuses associated with the war on terror, and which has led investigations into Ahmed Diini’s case for eight months, says this is the most compelling evidence of British complicity in torture since 2008. The case is now being investigated by the United Nations Human Rights Committee.

Asim Qureshi, research director at CAGE UK, said: “The case of Ahmed Diini raises serious questions over the Government’s treatment of the Somali community. The MI5 harassment he was subjected to over here echoes the testimonies of many other Somali youngsters.”

Daily coronavirus briefing No hype, just the advice and analysis you need Enter your email address Continue Continue Please enter an email address Email address is invalid Fill out this field Email address is invalid Email already exists. Log in to update your newsletter preferences Register with your social account or click here to log in I would like to receive morning headlines Monday - Friday plus breaking news alerts by email Update newsletter preferences

He added: “The alleged British involvement in his detention and torture in Egypt shows that, sadly, our Government has not changed its ways.”

Ahmed Diini left the UK to marry a German woman in 2011 but while he was away he was served with an exclusion order signed by the Home Secretary, who accused him of being involved in Islamic extremism. Unable to return to the UK he took his wife and children to live in Egypt. In March this year he was freed by the Egyptians without charge but on his way back to Holland he was arrested in Istanbul on a US arrest warrant. He is currently in prison in Turkey awaiting further requests from America which has accused him of being a member of al Shabaab, the Somalia-based terrorist organisation.

Mr Diini’s family escaped Somalia when he was three and he has not been back. He first settled in Holland and is a Dutch national but he had moved to Britain where he had studied and worked as a security guard at a school.

On Monday his younger brother, Mahamuud Diini, 24, who lives in Birmingham, told The Independent: “I believe that the MI5 officers by their actions and omissions were complicit in the detention, abuse and torture my brother suffered in Egypt.”

He added: “I saw how my brother’s life was made miserable by MI5 when he lived in the UK and how they continued to make life difficult for him while he was in Egypt. My brother has never had anything to do with al Shabaab.”

A spokesman for the Egyptian embassy in London said the allegations would be investigated but was unable to comment. MI5 declined to comment on the case.

Torture allegations: timeline

2001: British terror suspects and enemy combatants captured in Afghanistan by US forces are flown to Guantanamo. Some are held first at the US Bagram air base near Kabul. Many claim that the UK was involved in their rendition and torture.

2005: Jack Straw tells the Commons Foreign Affairs Committee: “Unless we all start to believe in conspiracy theories and that the officials are lying, that I am lying, that behind this there is some kind of secret state which is in league with some dark forces in the United States… there simply is no truth in the claims that the United Kingdom has been involved in rendition.”

2010: UK Government pays Guantanamo detainees up to £20m in return for dropping their claims of British complicity in torture and rendition.

2011: Tony Blair tells the BBC Radio 4 Today programme: “When our security services were co-operating with other countries in fighting terrorism they were absolutely right. They were doing a great job. Of course they should not break the rules or engage in torture but they were engaged in protecting our country. As a result we have significantly reduced the risk.”

2012: Ministers agree to pay more than £2m to the family of a prominent Libyan dissident abducted with the help of MI6 and secretly flown to Tripoli where he was tortured by the security police of the dictator Muammar Gaddafi.

2013: The Gibson inquiry into UK complicity in torture and rendition concludes that the British government and its intelligence agencies had been involved in rendition operations, in which detainees were kidnapped and flown around the globe, and had interrogated detainees whom they knew were being mistreated.

2013: Sir John Sawers, the head of MI6, tells MPs: “We have learned a huge amount over the past 12 years. There is no way that our members of staff could be drawn into situations, at this stage, where there is any doubt about what they should be doing.”

2013: Andrew Parker, the head of MI5, tells the same group of MPs: “We do not participate, incite, encourage or condone mistreatment or torture and that is absolute.”