The legal body that oversees the U.K.'s intelligence community said on Friday that the U.K. government unlawfully spied on its citizens and violated human rights by accessing mass surveillance collected by its U.S. counterparts.

The Investigatory Powers Tribunal (IPT), which oversees the intelligence practices of GCHQ, MI5 and MI6, ruled that regulations allowing British intelligence agencies to access emails and phone records intercepted by the U.S. National Security Agency breached human rights law, reported the Guardian.

The mass surveillance program was apparently illegal for at least seven years, between 2007, when the Prism program was started, and 2014. Only in December did it become legal, when the government informed the public how the data collection was authorized.

It's the first time in IPT's 15-year history that it ruled against an intelligence agency. In December, the IPT ruled that the U.K.'s intelligence collection did not violate the European Convention of Human Rights, noted the BBC. But now, IPT says that prior to receiving additional information in December, the intelligence gathering did in fact violate rights.

The IPT stated in its ruling: "We would accordingly make a declaration that prior to the disclosures made and referred to in the Tribunal's Judgment of 5 December 2014, 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 pursuant to Prism and/or (on the Claimants' case) Upstream, contravened Articles 8 or 10 [of the European Convention of Human Rights]."

The ruling was made in response to complaints brought by a number of human rights groups, including Amnesty International, Privacy International and Liberty. Most of the spying programs in question were initially disclosed by former NSA contractor-turned-whistleblower Edward Snowden.

Rachel Logan, Amnesty International U.K.'s legal program director, said, "This is an historic victory in the age-old battle for the right to privacy and free expression."

"The UK government has been rumbled here. The government has been playing a cat and mouse game over surveillance - talking about 'national security' while trying to cover up unlawful behaviour in its use of private data.

"Governments around the world are becoming increasingly greedy and unscrupulous in the way they sweep up and use our personal information. This is about showing that the law exists to keep the government spooks in check."