An agreement by EU governments to give the US Homeland Security Department details of all passengers flying between the EU and the US has been cast in doubt by one of the EU’s top law officers.

The Advocate General, the top legal advisor of the European Court of Justice, says that last year’s air passenger data agreement must be annulled because it breached EU law.

The challenge to the agreement was taken by the European Parliament.

MEPs believed the EU Commission and the national governments had exceeded their powers in agreeing to give data on EU citizens to a foreign government.

In advice to the court published today, the Advocate General agrees with the MEPs.

He says the commission and the European Council were wrong to use Article 95 of the EU treaty, which deals with the circulation of data within the single market, as the legal basis for a measure intended to fight terrorism and international crime.

The Advocate General recommends that the court annuls the decision, which was taken during the Irish Presidency of the EU.

The Luxembourg-based European Court of Justice accepts the opinion of the Advocate General in about 80% of cases.