Police acted lawfully when they used anti-terror powers to detain the partner of a journalist who worked with National Security Agency secret-spiller Edward Snowden, Britain's Court of Appeal ruled Tuesday.
But the judge said journalists need stronger protection against arbitrary interference from the police.
David Miranda was held under the Terrorism Act for nine hours at Heathrow Airport in August 2013 while he was traveling from Germany to Brazil. He was carrying documents for his partner, Glenn Greenwald, including encrypted intelligence files leaked by Snowden.
Civil liberties groups criticized the use of anti-terror legislation, accusing the authorities of attempting to intimidate journalists.
The High Court ruled in 2014 that police acted lawfully. Three appeals court judges agreed on Tuesday, saying police exercised the power to stop and search arriving travelers "for a permitted purpose."
"They were entitled to consider that material in his possession might be released in circumstances falling within the definition of terrorism," said one of the judges, John Dyson.
The court rejected Miranda's argument that the detention was "an unjustified and disproportionate interference with his right to freedom of expression."
But the judges also said there should be stronger legal safeguards when the stop-and-search power is used against journalists, "to avoid the risk that it will be exercised arbitrarily." They said Parliament should decide on what form the safeguards should take.
Kate Goold of law firm Bindmans, which represented Miranda, said she welcomed the ruling that the anti-terror powers needed "to come in line with other legislation to ensure that the seizure of journalistic material is protected by judicial safeguards."