A BRITISH APPEALS COURT has ruled that the United Kingdom’s broad counterterrorism laws breach fundamental rights in a case involving the seizure of encrypted documents from David Miranda, the partner of Intercept co-founder Glenn Greenwald, at a London airport in 2013.

Miranda (pictured above) was detained and interrogated for nine hours at Heathrow Airport in August 2013 while he was assisting Greenwald’s reporting on documents about government mass surveillance leaked by National Security Agency whistleblower Edward Snowden.

Last year, the High Court in London dismissed a legal challenge brought by Miranda over the case on the grounds that it reasonably regarded his actions as “terrorism” as defined by the law. However, that decision was partially overturned Tuesday by the Court of Appeal in a ruling that will be viewed as a major victory for press freedom campaigners.

The ruling finds that the police followed the law when detaining Miranda under a controversial section of the Terrorism Act, Schedule 7. However, crucially, it asserts that the statute itself “is not subject to adequate safeguards against its arbitrary exercise” and is “incompatible” with Article 10 of the European Convention on Human Rights, which provides the right to “receive and impart information and ideas without interference by public authority and regardless of frontiers.”

The Court of Appeal’s most senior judge, Lord Dyson MR, stated in the ruling that he accepted there were already some “constraints on the exercise of the power,” but he believed that these “do not afford effective protection of journalists’ Article 10 rights.” He added:

The central concern is that disclosure of journalistic material (whether or not it involves the identification of a journalist’s source) undermines the confidentiality that is inherent in such material and which is necessary to avoid the chilling effect of disclosure and to protect Article 10 rights. If journalists and their sources can have no expectation of confidentiality, they may decide against providing information on sensitive matters of public interest. That is why the confidentiality of such information is so important.

Miranda’s appeal was supported by a press freedom litigation fund established by First Look Media, The Intercept’s parent company. It was also supported by the rights groups Liberty, Article 19, English PEN, and the Media Defense Initiative. The latter three organizations argued in a joint submission to the court that the treatment of Miranda “raised very serious concerns about the adequacy of the safeguards available in the United Kingdom for those undertaking, or assisting in, journalist work in the public interest, or their sources.”

Miranda, a Brazilian national, was detained in London at the height of the international fallout from the Snowden revelations, which featured major disclosures about British mass surveillance programs. At the time of his August 2013 detention, Miranda was transporting a batch of the Snowden documents from one reporter to another — from Laura Poitras in Berlin to Greenwald in Rio de Janeiro. Poitras had been working on stories sourced from the Snowden material with the New York Times and Der Spiegel, while Greenwald was reporting for The Guardian, which had paid for Miranda’s trip. (Greenwald, who was then a columnist for the London-based newspaper, left in October 2013 to co-found The Intercept with Poitras.)

Shortly after Miranda was detained, British authorities claimed that encrypted material seized from him included 58,000 “highly classified” British documents derived from the Snowden leaks, 75 of which they said they had “reconstructed” and been able to decrypt and view. The seizure of the documents led to the London police counterterrorism division launching a criminal investigation that focused in part on journalists who had handled the files. The probe, which was designated the code name “Operation Curable,” remained ongoing as recently as November of last year, The Intercept has previously reported.

To justify their seizure of the documents, British authorities had argued that publication of the Snowden files was itself a terrorist act. A memo circulated by security services prior to Miranda’s detention asserted that “the disclosure [of the Snowden documents], 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.” This position was seemingly accepted by the High Court in February 2014, which ruled in favor of the government in a ruling staunchly criticized by press freedom groups such as Reporters without Borders. It also appeared to concern the U.K. government’s independent reviewer of terrorism laws, David Anderson, who warned in a July 2014 report that the High Court ruling had set a precedent that could mean in some cases that the “writing of a book, an article or a blog may therefore amount to terrorism.”

The appeals court’s judgment, however, appears to overturn this aspect of the High Court’s earlier ruling, significantly reining in its conflation of journalism with terrorism. It makes clear that under the European Convention on Human Rights, journalists are entitled to legal protections and should not be subjected to arbitrary stops and searches under counterterrorism laws. The law used to detain Miranda will now have to be changed so that journalists are better protected in the future.

Kate Goold, a lawyer for the London firm Bindmans who represented Miranda in the case, said that Tuesday’s ruling “emphasizes the importance of interpreting terrorism with its ordinary natural meaning to ensure that legitimate public interest journalism is not stifled through the use of draconian powers.”

“The notion of a journalist becoming an ‘accidental terrorist’ has been wholeheartedly rejected,” Goold said. “We welcome this court’s principled and decisive ruling that Schedule 7 needs to come in line with other legislation to ensure that the seizure of journalistic material is protected by judicial safeguards.”

Responding to the news Tuesday, Miranda tweeted that he was “Thrilled with the court ruling!” He added: “My purpose was to show U.K.’s terrorism law violates press freedoms. And journalism isn’t ‘terrorism.’ We won!”

The British government could attempt to launch a challenge against the Court of Appeal’s ruling with the U.K.’s Supreme Court. However, it was not immediately clear whether it intends to pursue the case further.

A spokesperson for the government’s Home Office insisted in a statement Tuesday that the appeals court’s ruling regarding Miranda’s detention “supports the action taken by police to protect national security.”

The spokesperson added: “We also note the court’s decision that Schedule 7 [of the Terrorism Act], as in force at the time of this incident, did not provide sufficient protection against the examination of journalistic material.

“The government is constantly working to ensure our counterterrorism powers are both effective and fair. That is why in 2015 we changed the Code of Practice for examining officers to instruct them not to examine journalistic material at all. This goes above and beyond the court’s recommendations in this case.”

Update: January 19, 9:45 a.m.

This post has been updated to include comment from the U.K. government.