Police are examining tens of thousands of documents which David Miranda had stored on his laptop and other electronic devices when he was stopped and held for nine hours under counter-terrorism laws.

Officers from Scotland Yard’s counter-terrorism command, SO15, have yet to complete their examination of the material but they believe its disclosure would be “gravely injurious to public safety”, a court heard.

Jonathan Laidlaw QC, appearing for Scotland Yard to oppose a legal challenge by Mr Miranda, said: “That which has been inspected contains, in the view of the police, highly sensitive material the disclosure of which would be gravely injurious to public safety and thus the police have now initiated a criminal investigation.

“I am not proposing to say anything else which might alert potential defendants here or abroad to the nature and the ambit of the criminal investigation which has now been started.”

He added that the material amounted to “tens of thousands of highly classified UK documents”.

Details of the inquiry emerged for the first time as lawyers for Mr Miranda won a limited injunction to stop police carrying out further examination of the data seized as he was in transit through the airport on Sunday August 18.

Mr Miranda was granted a temporary order against the police but, crucially, officers will be allowed to continue analysing the data “for the purposes of national security”.

The broad exception means the police will be able to continue most, if not all, of the work which Mr Miranda was seeking to block.

Under the terms of the order, the Metropolitan Police and the government will even be allowed to share information with foreign agencies – such as the CIA.

Mr Justice Beatson and Mr Justice Kenneth Parker, sitting at the High Court in London, also said the Met could investigate whether Mr Miranda was a “person who is or has been concerned in the commission, preparation or instigation of acts of terrorism”.

Mr Miranda was carrying documents on behalf of his partner Glenn Greenwald, a journalist with the Guardian newspaper who has made a series of disclosures from former CIA employee Edward Snowden about US intelligence capabilities.

He was detained under controversial powers in Schedule 7 of the Terrorism Act 2000 which allow police to detain anyone at a port or airport for up to nine hours if they are suspected of involvement in “acts of terrorism”.

Mr Greenwald has indicated we would be “more aggressive” in his reporting as a result of his partner’s detention, saying: “I am going to publish things on England too. I have many documents on England’s spy system. I think they will be sorry for what they did.”

David Anderson QC, the independent reviewer of terrorism legislation, said he would investigate whether the anti-terror powers had been “lawfully, appropriately and humanely used”.

A Home Office spokesman said: “We are pleased the court has agreed that the police can examine the material as part of their criminal investigation insofar as it falls within the purposes of the original Schedule 7 examination and in order to protect national security.

“It would be inappropriate for us to comment further on ongoing legal proceedings.”

A Scotland Yard spokesman said: “Initial examination of material seized has identified highly sensitive material, the disclosure of which could put lives at risk.

“As a result the Counter Terrorism Command has today begun a criminal investigation.”

The Home Office and Scotland Yard will have to provide more evidence of the threat posed by the material at another hearing next week.