A British man who was held in Guantánamo Bay has begun a civil action against MI5 and MI6 over the tactics that they use to gather intelligence.

The suit has been brought by Tarek Dergoul, 29, who claims he was repeatedly tortured while he was held by the US, and that British agents who had also questioned him were aware of the mistreatment.

He wants a high court ruling that will ban the security services from "benefiting" from the abuse of prisoners being held in detention outside the UK.

If Mr Dergoul wins, it would mean that MI5 and MI6 could not interrogate British nationals while they are being held and tortured abroad.

A British citizen, he has been awarded legal aid for the case, and papers will be lodged at the high court today. They were drafted by the Rabinder Singh, QC, a leading human rights barrister from the Matrix Chambers.

According to court documents seen by the Guardian, Mr Dergoul alleges that agents from MI5 and MI6 repeatedly interrogated him while he was held and tortured in Afghanistan and then Guantánamo, and were thus complicit in his treatment. In the 13-page document to be lodged at court, he says he suffered beatings, sexual humiliation, insults to his religion, and was subjected to extremes of cold. He was released back to Britain in 2004 without charge.

Britain says it does not carry out or condone torture, but it stands accused of benefiting from inhumane treatment meted out by other countries.

Mr Dergoul is seeking damages for "misfeasance in public office" by the security services and the Foreign Office.

The court papers state: "The British government and its officials knew that the claimant was being subjected to mistreatment amounting to torture and inhumane and degrading treatment because he told them so...Accordingly the British government and its officials unlawfully sought to benefit from mistreatment of the claimant. It is averred that either the British officials knowingly unlawfully interrogated the claimant or they acted with reckless indifference to its illegality."

Mr Dergoul said he was picked up in Afghanistan in 2001 by local warlords who "sold" him to the US for $5,000.

He denies involvement in fighting or terrorism and says he went to the region to study Arabic. He was held for a month at the prison in Bagram then spent three months in Kandahar before being sent to Guantánamo Bay.

He says one week after his arrival at Bagram, British agents first questioned him, identifying themselves only by their first names, "Andrew" and "Matt" and was questioned in front of an armed US soldier. He says he was kept in a cage with 20 others and saw horrific acts of torture inflicted on prisoners.

"They would be severely beaten, often with baseball bats, when they collapsed from exhaustion. The claimant also observed two or three men being hung by their hands with bags over their heads. The claimant also heard gunshots and screams," the papers say.

Mr Dergoul says he was moved to Kandahar, suffering more torture and denial of medical treatment that led to a toe being amputated. Again he says he was visited and interrogated by the British. One of the officials was 'Matt' whom he had previously seen at Bagram and the other man was in his early 40s and short."

In 2002, hooded, drugged and shackled Mr Dergoul was taken to Guantánamo, where he says UK agents questioned him five times, at intervals of every four to five months. In Guantánamo the Briton says he suffered more abuse and torture, which he says he told UK officials about.

"The claimant complained that he was being beaten and was being sexually assaulted by having his genitals touched during searches. The claimant also complained that he had been repeatedly attacked..., that he had been placed in freezing conditions in isolation without access to a toilet, water or soap, that he had had his facial hair forcibly shaved."

The government is expected to fight the court action.

Last night Mr Dergoul said: "This action comes at a time when people all over the world need protection from torture and abuse by governments which say they represent and uphold human rights."

The government confirmed last night that security service agents had interviewed Mr Dergoul and other Britons held in Guantánamo "about the UK's national security" adding "it was important that we got as much information as possible. They were arrested in unusual circumstances. British officials who visited them acted with the highest degree of professionalism."

The Foreign Office said: "The UK unreservedly condemns the use of torture. The British government, including its intelligence and security agencies, never use torture for any purpose, including obtaining information, nor would we instigate actions by others to do so." It said it could not comment on ongoing legal proceedings.