A mass surveillance programme by the UK government violated human rights, the European Court has ruled.
In a landmark case brought by charities including Amnesty and human rights group Big Brother Watch, the top court ruled that the "bulk interception regime" breached rights to privacy.
It comes after US whistleblower Edward Snowden revealed British surveillance and intelligence-sharing practices.
The former CIA employee revealed the security services had been collecting bulk data, including telephone calls, messages and internet communication, whether or not people were suspected of a crime.
In the ruling, judges declared there was insufficient monitoring of what information was being collected, which breaching the convention.
Judges were concerned about the lack of safeguards published which would explain when and why confidential journalistic information could be examined.
They wrote: "In view of the potential chilling effect that any perceived interference with the confidentiality of journalists' communications and, in particular, their sources might have on the freedom of the press, the Court found that the bulk interception regime was also in violation of article 10."
The court also ruled "the regime for obtaining communications data from communications service providers" violated the same part of the code of human rights.
The bulk interception regime also violated article 10, the court ruled, because there was not enough protection to ensure the safety of confidential journalistic sources.
However the court ruled that sharing the information with foreign governments did not break the code.
Three applications were joined together, from Big Brother Watch, the Bureau of Investigative Journalism, and 10 human rights charities, and were lodged after Mr Snowden's revelations.
All applicants felt their line of work meant they were more subject to having their communications intercepted by intelligence services.
The complaints centred on articles 8 and 10 of the convention of human rights, which protect a right to a private family life, and freedom of expression, with applicants saying bulk interception breached both.
However the court did rule a bulk operation on its own does not break the convention, so long as six key requirements are met, and because there was not enough independent oversight of the search and selection processes, there was a violation of the code.
Judges on the case did not agree with the applicants over issues of sharing the information with foreign governments, ruling there was no evidence of abuse or significant shortcomings.
Sky's technology correspondent Roland Manthorpe said: "There was some ambiguity in the judgement.
"While some activists may expect the court to outlaw all bulk interception, the court seems to say the principle is OK - it's the government's practice which was illegal."