The mass collection of communications data by Britain’s security agencies like GCHQ, MI5, and MI6 was unlawful, a preliminary finding by Europe’s highest court has suggested.

Under UK law, intelligence agencies are allowed to force telecoms companies such as Vodafone and O2 to hand over all data they hold on their customers. The data acquired by the security agencies can include call logs, location data, and all other metadata stored with communications companies.

However, a non-binding legal opinion from the Court of Justice of the European Union advocate general (AG) Campos Sánchez Bordona has stated that such request is unlawful under EU regulations.

In his 15-page opinion, Mr Bordona said that European case law around the protection of personal data should “preclude” any national legislation.

He also said that a national court can only force telecoms companies to relay personal data on a “exceptional and temporary basis” and that the requests must be targeted rather than indiscriminate.

Should the court comply with its AG’s opinion it will likely frustrate efforts by the UK government to agree a post-Brexit data protection regime. Due to the cross-country nature of telecoms companies the UK will need to align somewhat with European regulations.