The Investigatory Powers Tribunal said that the intelligence agency known as GCHQ, or Government Communications Headquarters, had not been open enough about the way the process worked until December.
The tribunal's ruling was in response to a complaint brought by civil liberties groups Liberty, Privacy International and Amnesty International in the wake of claims by former NSA contractor Edward Snowden
about mass U.S. surveillance programs such as Prism.
Snowden's revelations led to questions over GCHQ's sharing of surveillance data with the United States.
"Today's landmark ruling is the first time the Tribunal -- which considers complaints brought against GCHQ, MI5 and MI6 -- has found against the intelligence agencies in its 15-year history," Liberty said in a statement
, referring also to Britain's other two intelligence agencies.
"Liberty disagrees that the limited safeguards revealed are sufficient to make GCHQ's mass surveillance and intelligence-sharing activities lawful, and will challenge the Tribunal's December decision at the European Court of Human Rights."
'Monumental leap forward'
Privacy International also hailed what it said was a "major victory"
in the battle to rein in the intelligence agencies' activities.
Friday's judgment "represents a monumental leap forward in efforts to make intelligence agencies such as GCHQ and NSA accountable to the millions of individuals whose privacy they have violated," it said.
The tribunal ruled on December 5 that the sharing of electronic surveillance data between the two countries was lawful.
But it said Friday that only after that date was enough information about the program in the public domain -- thanks to the disclosures made in the case -- for the UK government not to contravene its European human rights obligations.
At issue are articles 8 and 10 of the European Convention on Human Rights, or ECHR, regarding the rights to privacy and to freedom of expression.
Before December 5, "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 US authorities ..., contravened Articles 8 or 10 ECHR, but now complies," the tribunal's ruling stated.
Government 'committed to transparency'
The UK Home Office said the ruling vindicated the intelligence agencies' actions.
"Today's judgment reaffirms the (tribunal)'s earlier ruling, which found that the current regime governing both the intelligence agencies' external interception and intelligence sharing regimes are lawful and ECHR compliant," a government spokesman said.
"Those activities have always been subject to strict safeguards. This judgment is about the amount of detail about those safeguards that needed to be in the public domain. The (tribunal) has made clear that no further action is required."
The government is "committed to transparency" and has now made public the detail of the safeguards governing requests made to foreign governments for intercepted communications, he added.
The Investigatory Powers Tribunal is an independent body set up to investigate complaints about the alleged conduct of public bodies with regard to members of the public.
It deals with complaints about the use of intrusive powers such as wiretapping by intelligence services, law enforcement agencies and public authorities.
Eric King, deputy director of Privacy International, said that despite Friday's ruling, more needed to be done to protect the UK public's rights.
"We must not allow agencies to continue justifying mass surveillance programs using secret interpretations of secret laws. The world owes Edward Snowden a great debt for blowing the whistle, and today's decision is a vindication of his actions.
"But more work needs to be done. The only reason why the NSA-GCHQ sharing relationship is still legal today is because of a last-minute clean-up effort by government to release previously secret 'arrangements.' That is plainly not enough to fix what remains a massive loophole in the law."