A British lower court has ruled that London police acted lawfully in employing an anti-terror statute to detain and interrogate David Miranda for nearly nine hours at Heathrow Airport last summer, even while recognizing that the detention was “an indirect interference with press freedom.”

Miranda, a Brazilian national, was carrying secret documents leaked by NSA whistleblower Edward Snowden from one reporter to another — from Laura Poitras in Berlin to Miranda’s partner, Glenn Greenwald, in Rio de Janeiro.

Greenwald and Poitras have published extensive revelations from the documents that Snowden provided them, primarily at the Guardian and the New York Times; both are now editors at The Intercept. Greenwald was working for Guardian US at the time.

In a decision released Wednesday morning, three judges on London’s High Court of Justice ruled that while Miranda’s detention was “an indirect interference with press freedom” it was justified and legitimate due to “very pressing” issues of national security.

The review of Miranda’s detention was widely seen as a test of how far governments that have adopted aggressive anti-terror policies will go — and will be allowed to go — in terms of treating journalists who expose secrets as criminals and terrorists themselves.

And yet, the ruling was not entirely surprising; the UK has historically been an outlier when it comes to both press freedoms and anti-terror policies.

Miranda said his suit will continue. “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,” he said in a statement to The Intercept.

Though Miranda’s case was heard in what is called the High Court, that is only the first level of judicial review in the UK. Two more remain within the British legal system, followed by the European Court of Human Rights.

“I’m of course not happy that a court has formally said that I was a legitimate terrorism suspect, but the days of the British Empire are long over, and this ruling will have no effect outside of the borders of this country,” Miranda added. “I’m convinced they’ve hurt their own country far more than me with this ruling, as it emphasizes what the world already knows: the UK has contempt for basic press freedoms.”

Home Secretary Theresa May praised the ruling saying, “This judgment overwhelmingly supports the wholly proportionate action taken by the police in this case to protect national security.”

May added, “Although the courts have fully supported the use of schedule 7 [of the UK anti-terrorism act] in this case, we constantly work to ensure that our counter-terrorism powers are effective and fair. That is why parliament has recently approved further safeguards proposed by the government for the use of this essential border and ports security power.”

London’s Metropolitan Police said it was “pleased” with the court’s decision, adding that the anti-terror statute invoked to justify Miranda’s detention is a “key part of our national security capability and a vital tool used by the police to help keep the public safe.”

“We carefully considered the use of schedule 7 in this case and our assessment was that the use of the power was legally and procedurally sound,” the police said.

According to documents made public during Miranda’s civil suit, police determined that he was subject to the anti-terror law because he was “likely to be involved in espionage activity” and met the technical definition of a terrorist because he was “knowingly carrying material, the release of which would endanger people’s lives” and was promoting a “political or ideological cause.”

After the police’s justification was made public in November, leading UK human rights groups and a member of the British parliament expressed outrage, saying it appeared baseless and threatened to have damaging consequences for investigative journalism, the Guardian reported .

Greenwald told The Intercept the UK has the unique distinction of being the only foreign government that has equated the NSA coverage he and Poitras are responsible for to terrorism.

“The journalism Laura and I have done with the Guardian and other major news organizations has spawned international debate and reform, and has been honored with top journalism awards all over the world, but it is only in the UK where our journalism is considered not just criminal but ‘terrorism’,” he said in a statement.

“We made clear long ago that we would not ever be deterred in any way in reporting aggressively on these documents by this kind of thuggish behavior from the British government, and we have been and will continue to be very true to our word,” Greenwald added. “It is ironic that as the world rightfully condemns the Egyptian military regime for imprisoning Al Jazeera journalists on the ground that their journalism is a form of ‘terrorism’, the UK Government yet again shows the repressive company it keeps by doing the same.”

Miranda was stopped at Heathrow airport at 8 a.m. August 18, 2013 while en route to the home he shares with Greenwald in Rio de Janeiro. He was traveling from Berlin, where he had met with Poitras. The Guardian paid for Miranda’s flight, as he was transporting materials related to the NSA stories.

The officers who stopped Miranda informed him that he would be questioned under schedule 7 of the UK’s terrorism act. The controversial law, enacted in 2000, aims to prevent individuals who may be involved in the “commission, instigation or preparation of acts of terrorism” from entering the country. The law – which critics say unfairly targets minority communities – does not require “probable cause” or an identifiable suspicion to justify a detention. Subjects are not afforded an automatic right to legal counsel and refusal to cooperate with the process is considered a criminal offense.

Under schedule 7, subjects can be held for up to nine hours. While the vast majority of detentions are concluded in under an hour, Miranda’s detention very nearly met the full maximum of nine hours. His personal belongings were seized, including his laptop, cell phone, two memory sticks, a pair of DVDs, a Sony video game console and a hard drive.

Upon returning to Brazil, Miranda said British authorities threatened to imprison him if he did not cooperate. He said he was not questioned about his alleged role in terrorism or his relationship to terrorist groups, though he said he was asked about Snowden, Poitras and Greenwald.

Miranda’s detention sparked anger in his home country. The government of Brazil issued a statement asserting his detention was “without justification since it involves an individual against whom there are no charges that can legitimate the use of that legislation.”

As news of the incident broke, some British politicians raised doubts about the application of the terrorism law. “The clause in this act is not meant to be used as a catch-all that can be used in this way,” said Labour MP Tom Watson. “It’s almost impossible, even without full knowledge of the case, to conclude that Glenn Greenwald’s partner was a terrorist suspect,” he added.

White House spokesman Josh Earnest confirmed the UK had provided a “heads up” that Miranda was going to be detained, but that it “was not something we requested.”

On August 20, two days after Miranda’s detention, Britain’s Home Office moved to aggressively defend the action, arguing he was in possession of “highly sensitive stolen information that would help terrorism” and revealing that Prime Minister David Cameron was given advance warning of the police operation.

“The government and the police have a duty to protect the public and our national security,” a Home Office spokesperson said. “Those who oppose this sort of action need to think about what they are condoning.”

Miranda filed a legal action against the British government, and in November the court disclosed a Ports Circulation Sheet (PCS) detailing the official assessment offered to explain why Miranda should be stopped. The undated document was prepared by Scotland Yard in consultation with the counterintelligence agency MI5, and was distributed to British border posts in advance of Miranda’s arrival.

“Intelligence indicates that Miranda is likely to be involved in espionage activity which has the potential to act against the interests of UK national security. We therefore wish to establish the nature of Miranda’s activity, assess the risk that Miranda poses to national security and mitigate as appropriate,” the PCS said. “We assess that Miranda is knowingly carrying material, the release of which would endanger people’s lives. Additionally the disclosure or threat of disclosure is designed to influence a government, and is made for the purpose of promoting a political or ideological cause. This therefore falls within the definition of terrorism and as such we request that the subject is examined under schedule 7.”

Miranda’s attorneys argued that the stop was unlawful and a violation of Miranda’s right to freedom of expression. And they said his detention marked the first time the terrorism act had been implemented to seize journalistic materials.

Home Office attorney Stephen Kovats conceded that the material was journalistic in nature. He added, however, “We do not understand that raw ‘Snowden data’ is journalistic material.”

The government argued that it had to intercept the material Miranda was suspected of carrying, lest it fall into the wrong hands. Miranda’s attorneys, meanwhile, said that if the government wanted the Snowden documents, it should have put in an application to a judge prior to the stop. Attorney Mathew Ryder said the government was appealing to “doomsday scenarios” rather than responsibly considering whether the terrorism act had been proportionately applied.

Tuesday’s decision found the judges on the side of the government. Lord Justice Laws, with whom the two other judges concurred, wrote that it was clear the authorities stopped Miranda to “ascertain the nature of the material he was carrying.” He added 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.”

Miranda said he has no regrets. “I am very proud of the work I did,” he said. “In fact, in light of today’s decision equating journalism with terrorism, I am more certain than ever that I did the right thing, since governments like this really need transparency.”

UPDATE AT 7:45 A.M. EST: Greenwald has published a blog post on The Intercept: On the UK’s Equating of Journalism with Terrorism. The Guardian is providing live coverage of reaction to the decision.

Edited by Dan Froomkin.