A journalist's partner, who was held for nine hours at Heathrow under anti-terror laws, has lost his UK High Court claim that he was detained unlawfully.

Brazilian David Miranda lives with 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 newspaper and other news publications, and one of the leading figures in writing those articles was Mr Greenwald.

The court rejected Mr Miranda's claim that his detention by police at the airport last August under Schedule 7 of the Terrorism Act 2000 was both unlawful and a breach of his human rights.

Mr Miranda was in transit from Germany to Brazil when he was stopped at the airport, detained, questioned and searched by police.

He had nine items, including his laptop, mobile phone, memory cards and DVDs, taken from him while detained.

A coalition of ten media and free speech organisations intervened in the case to express their concerns about the use of anti-terror powers against journalists.

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 fell properly within Schedule 7.

Steven Kovats QC argued, on behalf of Home Secretary Theresa May, that her national security duty to establish the nature of Mr Miranda's activity was "consistent" with use by the police of Schedule 7.

Agreeing, Lord Justice Laws said the schedule 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".

The Home Secretary welcomed the ruling, saying: "This judgment overwhelmingly supports the wholly proportionate action taken by the police in this case to protect national security.

"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," she added.