The security service MI5 will have to address searching questions over its credibility following today's judgment and the withering criticisms of the service that emerged in court.

For years the security and intelligence agencies, backed up by the government, have insisted that they have no truck with torture. Jonathan Evans, the head of MI5, stated last October: "I can say quite clearly that the Security Service does not torture people, nor do we collude in torture or solicit others to torture people on our behalf."

In today's judgment, however, the Master of the Rolls, Lord Neuberger, flatly contradicted these assertions.

Instead, MI5 was said to have been suppressing information and providing MPs with misleading evidence. In short, Neuberger doubted that MI5's assurances could be trusted.

William Hague, the shadow foreign secretary, said the dramatic revelations showed there was "an urgent need to draw a line under this episode and restore British moral authority in the matter of allegations of complicity in torture".

He called on ministers "to assure the country that any other credible allegations of British complicity in torture are being fully investigated".

Andrew Tyrie, the chairman of the all party parliamentary group on extraordinary rendition, added: "This court ruling adds to the drip-drip of damaging information on the UK government's involvement in rendition, at great cost to the UK's credibility, to the morale of our security services, and to relations with our allies."

In the past the foreign secretary, David Miliband, has tried to address what security and intelligence officers describe as an acute dilemma.

"It is not possible to eradicate the risk of mistreatment. A judgment needs to be made," Miliband told MPs.

"We cannot act in isolation in order to protect British citizens."

British security and intelligence officials say that in the fight against international terrorism they have no choice but to cooperate with their counterparts in other countries, such as Pakistan or Saudi Arabia.

A grey area exists and in recent years there has been a stream of allegations relating to MI5 knowledge of the ill treatment of detainees in Pakistan, Egypt, Bangladesh, and elsewhere.

But as the Binyam Mohamed case has shown, the US has presented a unique problem, because neither MI5 nor MI6 like arguing with the security and intelligence agencies of Britain's closest ally.

Since September 11 Britain has connived, wittingly or otherwise, in the secret rendition by the CIA of British residents and others. Mohamed was not the only case. Miliband has had to admit that, contrary to earlier assurances, CIA flights carrying terror suspects for secret interrogation had twice landed on the British Indian Ocean territory of Diego Garcia.

Following a number of reports in the media, the cross-party parliamentary intelligence and security committee described in 2007 how MI5 contributed to the seizure of two British residents by the CIA, which secretly flew them to Guantánamo Bay in a move with "serious implications for the intelligence relationship" between Britain and the US.

The Security Service passed information to the Americans on Bisher al-Rawi, an Iraqi, and Jamil el-Banna, from Jordan, as they flew to the Gambia to set up a business there in 2002. Both men had lived in Britain for many years. MI5 alerted the CIA to their trip to Gambia. The CIA ignored MI5's request that they should not be seized.

Both MI5 and MI6 were "slow to appreciate" the post-September 11 change in US policy, the intelligence and security committee said.

Evidence, from the committee's reports and elsewhere, shows that MI5, MI6, and military intelligence officers were not trained properly or advised about Britain's domestic and international obligations in law, including the Geneva conventions.

The government has refused to publish the guidelines distributed to MI5, MI6, and military intelligence officers at the time. It has recently drawn up new guidelines, which it has now passed to the intelligence and security committee.

It is unclear what advice Witness B, the MI5 officer being investigated by the Metropolitan police for "possible criminal wrongdoing" in connection with Mohamed's interrogations in Pakistan, received from other MI5 officers. The high court made it clear in earlier hearings that more officers were involved. Mohamed himself has suggested Witness B is a scapegoat.

The government, meanwhile, says that MI5, MI6 and the police should be able to withhold evidence from defendants and their lawyers in civil cases for the first time. The move was prompted by claims by seven British citizens and residents that they were ill-treated, and in some cases tortured, in Guantánamo Bay with the knowledge of Britain's intelligence agencies.

The government has admitted that British intelligence officers interrogated a Briton at least five times while he was held in leg cuffs at Guantánamo.

The government's lawyer, Jonathan Sumption QC, wrote a letter to the court of appeal on Monday in which he protested about the withering criticism of MI5 in the draft copy of the Binyam Mohamed judgment. Here we present the letter in full, annotated by the Guardian's Ian Cobain