A policy governing the interrogation of terrorism suspects in Pakistan that led to British citizens and residents being tortured was devised by MI5 lawyers and figures in government, according to evidence heard in court.

A number of British terrorism suspects who have been detained without trial in Pakistan say they were tortured by Pakistani intelligence agents before being questioned by MI5. In some cases their accusations are supported by medical evidence.

The existence of an official interrogation policy emerged during cross-examination in the high court in London of an MI5 officer who had questioned one of the detainees, Binyam Mohamed, the British resident currently held in Guantánamo Bay. The officer, who can be identified only as Witness B, admitted that although Mohamed had been in Pakistani custody for five weeks, and he knew the country to have a poor human rights record, he did not ask whether he had been tortured or mistreated, did not inquire why he had lost weight, and did not consider whether his detention without trial was illegal.

Mohamed is expected to return to Britain soon after ending a five-week hunger strike at Guantánamo Bay, where he was being force-fed. After he was seen by British officials and a doctor over the weekend, the Foreign Office said he was medically fit to travel.

Cross-examined in the high court last year, Witness B acknowledged that Mohamed was in "an extremely vulnerable position" when he questioned him in Karachi in 2002. The MI5 officer admitted telling him that "he would get more lenient treatment if he cooperated", and said that he knew he was to be transferred to US custody.

Witness B was asked by Dinah Rose QC, for Mohamed: "Was it your understanding that it was lawful for Mr Mohamed to be transferred to the US authorities in this way?" Witness B replied: "I consider that to be a matter for the security service top management and for government."

Asked then whether the transfer concerned him, Witness B replied: "I was aware that the general question of interviewing detainees had been discussed at length by security service management legal advisers and government, and I acted in this case, as in others, under the strong impression that it was considered to be proper and lawful." He denied that he had threatened Mohamed and said the prisoner appeared well enough to be questioned.

Mohamed was eventually able to tell lawyers that before being questioned by MI5 he had been hung from leather straps, beaten and threatened with a firearm by Pakistani intelligence officers. After the meeting with MI5 he was "rendered" to Morocco where he endured 18 months of even more brutal torture, including having his genitals slashed with a scalpel. Some of the questions put to him under torture in Morocco were based on information passed by MI5 to the US.

The Guardian has learned from other sources that the interrogation policy was directed at a high level within Whitehall and that it has been further developed since Mohamed's detention in Pakistan. Evidence of this might emerge from 42 undisclosed US documents seen by the high court and sent to the MPs and peers on the intelligence and security committee (ISC).

Lawyers representing Mohamed went to the high court in an attempt to secure the disclosure of the documents, but the court reluctantly refused earlier this month after David Miliband, the foreign secretary, said such a move would damage national security and UK-US relations.

Miliband's position in the affair came under renewed attack yesterday after it emerged that his officials solicited a letter from the US state department to back up his claim that if the evidence was disclosed, Washington might stop sharing intelligence with Britain. The claim persuaded the high court judges to suppress what they called "powerful evidence" relating to Mohamed's ill-treatment.

Edward Davey, the Liberal Democrat foreign affairs spokesman, today described the move as possibly "one of the most outrageous deceptions of parliament, the judiciary and the British people. There must be an immediate investigation, with all related correspondence made public."

The FCO said it asked the US to make its position clear in writing "to inform both us and the court". It said it was "both perfectly sensible and the correct thing to do".

The high court said it was now up to the ISC to "hold those in charge of the secret intelligence service and security service and her majesty's government to account".

In a letter to the committee, Clive Stafford Smith, the director of Reprieve, says: "The ISC would want to know whether the intelligence services brought the issue of Mr Mohamed's abuse to the attention of the prime minister (then Mr Blair) – and, if not, why not." He said if the evidence had been brought to Blair's attention, "the ISC would want to know what, if anything, was done about it. If nothing was done, that would raise serious questions about the respect that the UK government has for its obligations under the convention against torture."

Evidence heard by the court in-camera – once the public and the media had been excluded – resulted in Jacqui Smith, the home secretary, asking the attorney general, Lady Scotland, to investigate "possible criminal wrongdoing" by both American and British security and intelligence officers.

Witness B's testimony is expected to be considered by MPs and peers on parliament's joint committee on human rights, which has begun an inquiry into allegations of British collusion in the torture of detainees in Pakistan, and is asking Miliband and Smith to give evidence.

A number of British terrorism suspects have been questioned by British intelligence officials, including MI5 officers, after periods of alleged torture by Pakistani interrogators. Last year Manchester crown court heard that MI5 and Greater Manchester police passed questions to Pakistani interrogators so they could be put to Rangzieb Ahmed, 35, from Rochdale. MI5 officers also interviewed him while he was in custody, although the head of the consular division at the British high commission was not informed about his detention for nine months. By the time Ahmed was deported to the UK 13 months later, and successfully prosecuted for terrorism offences, three of his fingernails had disappeared from his left hand. He says they were removed with pliers while he was being questioned about his associates in Pakistan, the July 2005 terrorist attacks in London, and an alleged plot against the United States.

While other detainees have also subsequently been prosecuted or deported to the UK and made subject to control orders, one vanished in bizarre circumstances and was subsequently said to have been killed in a US missile attack, although his family has not been given his body. A number have been released without charge.

A medical student from London who was held for almost two months in a building opposite the offices of the British deputy high commission in Karachi says he was tortured while being questioned about the 2005 London bombings before being questioned by British intelligence officers. He was released without charge and is now working at a hospital on the south coast of England, but is thought to remain deeply traumatised.