Human rights activists in the UK have vowed to appeal against a ruling that a policy allowing MI5 to authorise informants to commit serious criminal offences - potentially including murder, kidnap and torture - is lawful.
Privacy International, Reprieve, the Committee on the Administration of Justice and the Pat Finucane Centre had asked the UK's Investigatory Powers Tribunal (IPT) to declare the British government policy unlawful and grant an injunction "restraining further unlawful conduct".
But the tribunal held by a 3-2 majority that MI5 does have the power to authorise the commission of criminal offences by informants.
Announcing the decision yesterday, IPT president Lord Justice Singh said: "This case raises one of the most profound issues which can face a democratic society governed by the rule of law."
The majority judgment said MI5 has "an implied power" under Britain's Security Service Act 1989 "to engage in the activities which are the subject of the policy under challenge".
But it added that "this does not mean that (MI5) has any power to confer immunity from liability under either the criminal law or the civil law".
Lord Justice Singh said that preventing MI5 from embedding an informant in a proscribed terrorist organisation because they would be committing a criminal offence "would strike at the core activities of the Security Service".
The judge added that it was "essential to run an agent in a proscribed organisation... for the gathering of intelligence, but also for disrupting activities of such organisations".
However - in what is believed to be the first time the tribunal has published a dissenting opinion - two members of the IPT found that the policy was in fact unlawful. Reprieve described it as a "knife-edge" judgment.
At a hearing in November, Ben Jaffey QC submitted that "in the past, authorisation of agent participation in criminality appears to have led to grave breaches of fundamental rights".
He pointed to the 1989 murder of Belfast solicitor Pat Finucane, an attack later found to have involved collusion with the state, and the case of Freddie Scappaticci, alleged to have been a senior member of the IRA and a security service agent under the codename Stakeknife.
A Home Office spokesman said: "The use of covert agents is an essential tool for MI5 as it carries out its job of keeping the country safe.
"We are pleased the tribunal found in the government's favour."