The UK government has nine months to come up with a new data retention law after the High Court ruled current legislation unlawful.

Internet and telecom companies had been ordered to retain data under stop-gap legislation.

Since the EU Data Retention Directive was ruled to violate fundamental privacy rights, many governments have introduced new data retention laws that would provide law enforcers with continued access to communications data.

Since the Court of Justice of the European Union ruling, the UK government rushed through parliament the Data Retention and Investigatory Powers Act 2014 (DRIPA).

Friday’s decision by the UK’s High Court ruled that Section 1 of DRIPA would not apply after March 31st, 2016.

David Davis, Conservative MP, said: "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."

The UK government plans to appeal the ruling, with the government’s Security Minister John Hayes warning that without the data retention laws lives could be at risk.

The communications data would only be available to the police and other law enforcement agencies if a communications company had retained it for commercial reasons.