Tens of thousands of secret documents carried through Heathrow airport by David Miranda could be harmful to national security and pose a risk to intelligent officers' lives if made public, national security adviser warns.

David Miranda
David Miranda (right) was question by officers at Heathrow airport for nine hours on 18 August. (Reuters)

The warning came from deputy national security adviser Oliver Robbins, as the High Court granted police power to investigate whether crimes of terrorism or breaches of Official Secrets Act were committed by Miranda.

A laptop, mobile phones, external hard drive and memory sticks were seized from Miranda, partner of Guardian journalist Glenn Greenwald, as he passed through Heathrow airport while travelling from Berlin to Rio de Janeiro, where he lives with the reporter.

Miranda, who denies wrongdoing and was travelling on behalf of Greenwald on a flight paid for by the Guardian newspaper, was stopped under schedule 7 of the Terrorism Act 2000 and questioned by officers for nine hours, the maximum time allowed without charge.

In a witness statement presented to the court, Robbins said one file seized from Miranda included 58,000 "highly classified UK intelligence documents".

"I can confirm that the disclosure of this information would cause harm to UK national security," Robbins said.

Police now have permission to examine the materials carried by Miranda.

Previously, the High Court had granted a temporary injunction that police could examine the seized material only for purposes of national security, and the court was due to meet again to decide whether to extend this injunction.

Miranda's lawyers said that he and other parties had reached an agreement allowing police to carry on examining the material.

Officers will be looking to determine whether a crime of "communication of material to an enemy" has been committed, as well as possible crimes of communication of material that could be useful to terrorists, such as information on members of the military and intelligence services.

Robbins' statement said the files carried by Miranda were "highly likely to describe techniques which have been crucial in life-saving counter-terrorist operations, and other intelligence activities vital to UK national security...The compromise of these methods would do serious damage to UK national security and ultimately risk lives."

Despite many of the files being encrypted, Miranda was said to be carrying a "piece of paper containing basic instructions for accessing some data, together with a piece of paper that included the password for decrypting one of the encrypted files on the external hard drive."

Only applicable in the transfer lounges of airports and ports, schedule 7 of the Terrorism Act 2000 grants officers permission to question suspects for up to nine hours without charge or arrest. In a YouGov poll just 37% of 1,858 British adults questioned agreed that it was appropriate to detain Miranda under the law.

Miranda's lawyer Matthew Ryder said his client's possessions were seized "under threat of criminal prosecution in a coercive use of schedule 7 which was unlawful."

Referring to stories published with information leaked by NSA whistleblower Edward Snowden, Greenwald said: "The UK government is incapable of pointing to a single story we have published that has even arguably harmed national security. The only thing that has been harmed are the political interests and reputations of the Uk and US officials around the world, as they have been caught engaging in illegal, unconstitutional and truly dangerous bulk surveillance aimed at their own citizens...all with little accountability or transparency - until now."

A Scotland Yard spokeswoman said: "As previously stated the Metropolitan Police Service Counter Terrorism Command is now carrying out a criminal investigation, which is at an early stage."