(Adds quote from Cameron's spokeswoman, other details)
By Estelle Shirbon
LONDON, Feb 6 (Reuters) - A British tribunal ruled on Friday that some aspects of intelligence-sharing between security agencies in Britain and the United States were unlawful until December 2014, in a ground-breaking case brought by civil liberties groups.
The Investigatory Powers Tribunal ruled that Britain's GCHQ had acted unlawfully in accessing data on millions of people in Britain that had been collected by the U.S. National Security Agency (NSA), because the arrangements were secret.
Campaign groups Liberty, Privacy International, Amnesty International and others brought the case following revelations about mass surveillance made by former NSA contractor Edward Snowden.
It was the first time in its 15-year history that the tribunal, which deals with legal challenges to Britain's GCHQ, MI5 and MI6, had issued a ruling that went against one of those security agencies.
The legal challenge forced the British government to reveal some details about the previously secret rules governing how GCHQ accessed data collected as part of the NSA's Prism and Upstream programmes, first revealed by Snowden in June 2013.
The tribunal ruled that "the regime governing the soliciting, receiving, storing and transmitting by UK authorities of private communications of individuals located in the UK, which have been obtained by U.S. authorities pursuant to Prism and ... Upstream" contravened human rights laws until the government's disclosures about how the arrangements worked.
A spokeswoman for Prime Minister David Cameron said the rules on intelligence-sharing were now fully lawful, adding: "The judgment will not require GCHQ to change what it does."
Material revealed by Snowden and cited by the civil liberties groups showed Prism allows the NSA to access data handled by the world's largest Internet companies, including Google, Yahoo, Facebook and others.
The groups hailed Friday's ruling as a major victory.
"We now know that, by keeping the public in the dark about their secret dealings with the National Security Agency, GCHQ acted unlawfully and violated our rights," Liberty's legal director James Welch said in a statement.
Friday's ruling followed on from a judgment by the same tribunal in December that Britain's legal regime governing mass surveillance of the Internet by intelligence agencies did not violate human rights.
The tribunal's concern, addressed in the new ruling, was that until details of how GCHQ and the NSA shared data were made public in the course of the court proceedings, the legal safeguards provided by British law were being side-stepped.
"Today's IPT ruling reaffirms that the processes and safeguards within the intelligence-sharing regime were fully adequate at all times," a GCHQ spokesman said. "It is simply about the amount of detail about those processes and safeguards that needed to be in the public domain."
The civil liberties groups are preparing to challenge the December ruling in the European Court of Human Rights, arguing that the limited safeguards revealed by the government were not enough to make GCHQ's activities compliant with privacy laws. (Additional reporting by Guy Faulconbridge and Kylie MacLellan; Editing by Catherine Evans)