A journalist's partner held for nine hours at Heathrow under anti-terror laws has reacted angrily to a High Court decision that police and security services were legally justified in detaining him and examining material he was carrying.
Lord Justice Laws, sitting in London with two other judges, said an external hard drive taken from Brazilian David Miranda contained "approximately 58,000 highly classified UK intelligence documents".
The judge ruled there was "compelling evidence" that stopping Mr Miranda was " imperative in the interests of national security", even though it constituted "an indirect interference with press freedom".
Mr Miranda, 28, is the partner of writer Glenn Greenwald, who exposed secret information on US surveillance leaked by whistle-blower Edward Snowden.
Articles based on some of the Snowden material were published by The Guardian and other news publications, and one of the leading figures in writing those articles was Mr Greenwald.
Mr Miranda plans to appeal against today's ruling. He said it emphasised "what the world already knows - the UK has contempt for basic press freedoms".
A coalition of 10 media and free speech organisations intervened in the case to express their concerns about the use of anti-terror powers against journalists.
Mr Greenwald said : "The UK Government expressly argued that the release of the Snowden documents, which the free world calls 'award-winning journalism', is actually tantamount to 'terrorism' - the same theory now being used by the Egyptian military regime to prosecute Al Jazeera journalists as terrorists.
"Congratulations to the UK Government on the illustrious company it is once again keeping."
But Home Secretary Theresa May welcomed the judgment and said it "overwhelmingly supports" action taken to protect national security.
She said: "If the police believe any individual is in possession of highly-sensitive stolen information that would aid terrorism, then they should act. We are pleased that the court agrees.
"The police and our intelligence agencies do a vital and difficult job protecting our lives and freedoms from terrorists, serious criminals and hostile states. Their job has been made much harder as a result of intelligence leaks."
Mr Miranda was detained by police at Heathrow Airport last August under Schedule 7 of the Terrorism Act 2000 while he was in transit from Germany to Brazil.
Nine items were taken from him, including his laptop, mobile phone, memory cards and DVDs.
Lord Justice Laws said it was plain that the purpose of stopping Mr Miranda "was to ascertain the nature of the material he was carrying" and to "neutralise" any threats it posed to national security. Thus it fell properly within Schedule 7.
The judge said Oliver Robbins, the UK's deputy national security adviser at the Cabinet Office, had stated that "release or compromise of such data would be likely to cause very great damage to security interests and possible loss of life".
In a written ruling, supported by Mr Justice Ouseley and Mr Justice Openshaw, the judge rejected submissions that the use of the anti-terror laws against Mr Miranda was an "unjustified and disproportionate" interference with the right to "protection of journalistic expression".
In a decision being seen by investigative journalists as a serious threat to press freedom, the judge declared that Schedule 7 was "capable of covering the publication or threatened publication... of stolen classified information which, if published, would reveal personal details of members of the armed forces or security and intelligence agencies, thereby endangering their lives..."
In a statement published on Mr Greenwald's new website, The Intercept, Mr Miranda said: "I will appeal this ruling, and keep appealing until the end; not because I care about what the British Government calls me, but because the values of press freedom that are at stake are too important to do anything but fight until the end."
Senior national co-ordinator of counter-terrorism Deputy Assistant Commissioner Helen Ball, of the Metropolitan Police, said: " This was a very important case that has attracted considerable public attention.
"Schedule 7 of the Terrorism Act 2000 is vital in helping to keep the public safe.
"We are pleased that the court's judgment states that 'The stop was lawful. It was also, on the evidence, a pressing imperative in the interests of national security'.
"Some commentators have characterised the stop as an attack on journalistic freedom. This was never the case."