The High Court has ruled the government's new data surveillance law is "inconsistent with EU law" following an appeal by MPs Tom Watson and David Davis.

The MPs challenged the Data Retention and Investigatory Powers Act (Dripa), passed by the coalition government last year, which gives the police and security services the right to access phone and internet records in the interest of public safety.

Conservative former shadow home secretary Davis and Labour backbencher Watson said the act gave the authorities permission to "spy on citizens" with no proper safeguards and is not compatible with a section of the European Convention on Human Rights (ECHR) which gives the right to respect privacy as well as the protection of personal data.

The High Court ruled on Friday (17 July) in favour of the MPs, who were also backed by human rights group Liberty, and declared that Dripa is "inconsistent with EU law".

It ruled that Dripa "does not lay down clear and precise rules providing for access to and use of communications data".

Prime minister David Cameron and his then deputy Nick Clegg had to quickly pass Dripra through parliament after the European Court of Justice made a ruling that would have denied authorities access to vital data about phone and email communications.

The act passed on the basis that communications companies keep data for 12 months in case they are needed for an investigation, but did not allow police or security services access to the data without a warrant.

There must be independent oversight of the Government\'s data-collection powers and there must be a proper framework and rules on the use and access of citizens\' communications data.\" - Tom Watson

The court has ruled the act must now be suspended until at least March 2016 so the government can have the "opportunity to put matters right".

Following the decision by the High Court, Watson said: "The government was warned that rushing through important security legislation would end up with botched law. Now the High Court has said they must come back to parliament and do it properly. The government gave MPs one day to discuss the legislation which was wrongly represented as respectful of people's right to privacy: it has until March 2016 to make sure that the law is rewritten.

"There must be independent oversight of the government's data-collection powers and there must be a proper framework and rules on the use and access of citizens' communications data."

Davis added: "The court has recognised what was clear to many last year, that the government's hasty and ill-thought through legislation is fatally flawed. They will now have to rewrite the law to require judicial or independent approval before accessing innocent people's data, reflecting the new consensus amongst experts in the Anderson and RUSI (Royal United Services Institute) reports. This change will improve both privacy and security, as while the government gave pParliament one day to consider its law, the court has given almost nine months."

James Welch, legal director for Liberty, said there is now a growing "chorus of voices" which are demanding change with regards to giving the government proper safeguards to gather data.

He added: "Campaigners, MPs across the political spectrum, the government's own reviewer of terrorism legislation are all calling for judicial oversight and clearer safeguards. The High Court has now added its voice, ruling key provisions of Dripa unlawful. Now is the time for the home secretary to commit publicly to surveillance conducted with proper respect for privacy, democracy and the rule of law – not plough on with more of the same."