MI5 grants its informants legal cover to participate in crimes that may extend to murder, torture and sexual assaults, a tribunal has heard.

The policy, in existence since the early 1990s, is likely to have enabled the Security Service to conceal wide ranging illegal activity, Ben Jaffey QC, representing an alliance of human rights group, told the investigatory powers tribunal (IPT) on Thursday.

The policy was so secret that even judicial oversight of the practice, introduced in 2012, was not initially acknowledged. Sir Mark Waller, a retired judge appointed to oversee the policy, was instructed by the prime minister at the time, David Cameron, not to comment on its legality.

Known within the intelligence services as “the third direction”, a letter from Cameron to Waller dated 27 November 2012 said his “oversight would not provide endorsement of the legality of the policy”.

Cameron continued: “You would not be asked to provide a view on whether any particular case should be referred to the prosecuting authorities; and your oversight would not relate to any future consideration given by prosecuting authorities to authorisations.”

Waller was the intelligence services commissioner at the time, charged with independent judicial oversight of the conduct of MI5, MI6 and GCHQ.

Cameron’s letter explained that in protecting national security, MI5’s agent-handlers permit informants to participate in “crime, in circumstances where it is considered [that] involvement is necessary and proportionate in providing or maintaining access to intelligence” that would disrupt more serious crimes or security threats.

He added that he had considered whether his letter should be published for transparency purposes, but “concluded that it should not on the basis that doing so would be detrimental to national security and contrary to the public interest”.

Some details of the policy were also disclosed on Thursday during the hearing. A heavily redacted copy of a three-page MI5 document, entitled Guidelines on the use of agents who participate in criminality (official guidance), was released.

The document shows that MI5 sought to give its agents even greater freedom to commit criminal offences than that usually proffered to police informers. “The service has established its own procedure for authorising the use of agents participating in crime,” it states.

It says any authorisation to commit crimes “has no legal effect and does not confer on either agent or those involved in the authorisation process any immunity from prosecution. Rather, the authorisation will be the service’s explanation and justification of its decisions” should the police investigate.

The IPT case, which is potentially embarrassing for the government, has been brought by Privacy International, Reprieve, the Committee on the Administration of Justice and the Pat Finucane Centre.

MI5’s policy is illegal if it breaches fundamental human rights, such as the ban on the use of torture, Jaffey told the tribunal.

The policy appears to be the equivalent of MI6’s powers created under the Intelligence Services Act 1994. Section 7 of the act is sometimes known as the “James Bond clause” because it provides a legal amnesty for spies to commit abroad what would otherwise be crimes.

The MI5 guidelines date back to the early 1990s and, it is believed, attempted to formalise the legal gap exposed earlier during the Troubles in Northern Ireland when special branch agent-handlers sought clarity from Downing Street on how far they were permitted to go in allowing informants to participate in crimes without facing prosecution themselves.

At that stage, in the 1980s, the office of the prime minister, Margaret Thatcher, was unwilling to give clear guidance. Those exchanges were carefully documented in the De Silva report into the murder of the Belfast lawyer Pat Finucane.

Sir James Eadie QC, representing the intelligence agencies, the Home Office and the Foreign Office, told the the IPT that details of MI5’s conduct had to be kept secret and could not be aired in open court. He argued that the claim should be restricted to investigating over a “sensible time period”, at most six years.

For part of the day, the IPT went into closed session from which the press, public and lawyers for the claimants were excluded.

Reprieve’s director, Maya Foa, said: “We want to know if it’s government policy to let MI5 agents get away with serious crimes such as torture and murder.

“While our intelligence agencies have an important role in keeping this country safe it does not follow that agents can be permitted to break the law without limits. If this is indeed the government’s position it must inform MPs and the public, and open the policy to legal and parliamentary scrutiny.”