MI5 has been ordered by a senior judge not to delete vast databanks of personal information it is storing pending the outcome of a trial over the legality of its surveillance procedures.

Lord Justice Singh, the president of the investigatory powers tribunal (IPT), delivered a sharp rebuke to lawyers for MI5 who questioned the feasibility of his legal directive.

“This is an order of a judicial tribunal,” Singh said. “If it turns out the respondents [MI5] have breached the orders of the tribunal that will have consequences.”

The IPT hears complaints about the operation of the intelligence services.

The sharp exchange between the judge and MI5’s lawyers came at the end of an opening hearing into a joint-claim by the human rights groups Liberty and Privacy International. Both have called for interception warrants obtained unlawfully by MI5 to be quashed.

The case is an attempt to establish the extent of internal failures – admitted last year by MI5 – over the way the Security Service captures, processes, stores and uses the bulk interceptions of data acquired through surveillance and hacking programmes.

MI5 has a duty to ensure such material is held no longer than required or copied more often than needed. It has been accused of operating “ungoverned spaces” where such regulatory duties were routinely ignored.

Previous IPT judgments may even need to be reopened, the tribunal was told on Monday by Daniel Cashman, representing Liberty and Privacy International. This was because MI5 had “breached it duty of candour” to the home secretary, the high court and the tribunal, Cashman added.

In a written claim submitted to the tribunal, Privacy International and Liberty said: “MI5 appears to have led ministers, the investigatory powers commissioners and judicial commissioners to grant warrants … on a false basis as to its arrangements for the retention, review and destruction of personal data obtained by bulk and other means over an extended period.”

That illegality may stretch back as far as 2010, according to the claim form. “There have been significant intrusions into individuals’ privacy, contrary to domestic law and without any justification, at a systematic level due to the creation and continued use, over a significant period, of inadequate systems for data retention, management and destruction,” it added.

Even though the claim was lodged on 31 January, Singh said EU law may no longer apply to the dispute.

The judge said the question of whether any past court or tribunal judgments need to be reopened should be stayed until after the claim has been concluded. But he ordered that MI5 should preserve evidence of any wrongdoing in its computers.

Andrew O’Connor QC, representing MI5, said there was already a “remediation process” going on in the agency that involved “the deletion of material that should not be there”.

Any order from the tribunal, he said, “requiring Thames House [MI5’s London headquarters] to put a freeze on any deletions would be in contradiction of a process agreed with the investigatory powers commissioner”.

O’Connor said he would need to take instructions from the Security Service and may need to make fresh representations to the IPT. “This is not something can halt by making a phone call,” he added.

