Judges voted six to one the effort by its intelligence agency GCHQ for obtaining data from communications providers was “not in accordance with the law”, and there were “insufficient safeguards in respect of confidential journalistic material”.

They also voted by five to two the mass trawling for information violated Article 8 of the European Convention on Human Rights guaranteeing the right to privacy.

The GCHQ programme was revealed by American whistleblower Edward Snowden, a former National Security Agency (NSA) operative, as part of his sensational leaks on US spying.

The UK case, brought by civil liberties, human rights and journalism groups and campaigners, challenged British surveillance and intelligence-sharing practices revealed by Snowden.

The judges ruled against the 16 complainants on the question of whether Britain further violated their privacy by sharing intelligence with foreign governments, saying that did not constitute a breach of their rights.

The verdict is not final and can be appealed.

‘Major victory’

Corey Stoughton of human rights group Liberty described the ruling as “a major victory for those of us who think there ought to be balance in the government’s ability to engage in surveillance”.

Britain has changed its surveillance laws since the legal challenge began, passing new legislation the government says has more privacy safeguards.

A UK government spokesperson said the government would “give careful consideration to the court’s findings” while noting a new “double lock” oversight mechanism on spying had been enacted in 2016 – three years after the revelations first emerged.

Snowden leaked thousands of classified documents to the media in 2013 that revealed the vast scope of surveillance of private data that was put in place after the September 11, 2001, attacks.

The documents showed Britain spied on foreign politicians at G20 summit meetings in London in 2009, and collected huge quantities of global email messages, Facebook posts, and internet histories and calls, which it shared with the NSA.__Al Jazeera