uk surveillance
Britain's highest court ruled that a controversial data collection and retention measure was unlawful. In this photo, graffiti art is seen on a wall near the headquarters of Britain's eavesdropping agency, Government Communications Headquarters, known as GCHQ, in Cheltenham, western England April 16, 2014. Reuters/Eddie Keogh

The U.K.'s highest court ruled on Friday that emergency surveillance legislation introduced last year, which empowered mass surveillance and data collection, is unlawful. The government will now have to pass new legislation that must come into effect by the end of next March, BBC reported.

The court ruled in favor of Labour Party lawmaker Tom Watson and Conservative Party lawmaker David Davis, overturning the Data Retention and Investigatory Powers Act (DRIPA) 2014 on the grounds that the data retention powers granted in the legislation were in violation of European Union law.

"The court has recognised what was clear to many last year, that the government's hasty and ill-thought through legislation is fatally flawed," Davis said, in a press release. "This change will improve both privacy and security, as whilst the government gave Parliament one day to consider its law, the court has given almost nine months."

DRIPA required all communications companies to store their customers' personal data for one year, tracking their phone and Internet usage and making it available to British authorities. The contentious law, which was pushed through the legislature in three days last June, granted the Government Communications Headquarters (GCHQ) and other intelligence agencies sweeping powers over Britons' personal communications.

In their legal challenge -- which was backed by the civil rights group Liberty -- Davis and Watson argued that the law violated European human rights standards, citing Article Eight of the European Convention on Human Rights, which guarantees the right to privacy and family life.

They argued that the use of communications data was not limited to serious criminal cases, and that there were insufficient mechanisms in place to inform people when their data was being retained by state authorities. Their challenge also pointed out that there was no respect for those under professional obligations of secrecy, such as lawyers or journalists, or sufficient safeguards against communications leaving the EU.

In its ruling, the court found that sections one and two of DRIPA were in violation of the article and said the law must be "disapplied."

"It's a year to the day since DRIPA received royal assent. Good governance is about allowing the legislature the room to make law," Watson said. "In this case it didn't happen. Good opposition is about holding governments to account and that didn't happen either."