Data retention from telephone calls and emails is legal only in some serious crime cases, according to a preliminary ruling by the European Court of Justice (ECJ) on a data retention case brought by UK MPs and privacy rights groups.

The types of data that can be retained include the date, time and duration of calls, and the source as well as destination of calls, excluding their content.

The opinion was issued at the request of courts in Sweden and the UK, where several individuals filed appeals against national legislation on data retention.

The ECJ's advocate general, Henrik Saugmandsgaard Oe, said a general obligation to retain data imposed by a Member State on providers of electronic communication services may be compatible with EU law.

Saugmandsgaard noted that governments need to satisfy strict requirements, including respecting the essence of the right to respect for private life and the right to the protection of personal data laid down by the Charter.

He said: "The fight against serious crime is an objective in the general interest that is capable of justifying a general obligation to retain data.”

But Saugmandsgaard said this obligation must be "strictly necessary to the fight against serious crime," and "proportionate".

Even though it is non-binding, the ECJ is likely to follow the advocate general’s opinion in its final verdict, which is anticipated later this year.

Labour’s deputy leader Tom Watson was quoted by the Guardian as saying, “The opinion makes it clear that information including browsing history and phone data should not be made available to the security services and other state bodies without independent authorisation.

“The security services have an important job to do, but judicial oversight is vital if we are to maintain the right balance between civil liberties and state power.”