What just happened? It seems the $14 billion tax battle Apple is waging against the EU has suffered a major setback. The European Court of Justice's top legal advisor just said that an earlier ruling in the case favoring the iPhone maker should be shelved.

Back in 2014, the European Commission started looking into the tax system of Ireland – home of Apple's European headquarters - and found that tech giants had been abusing it to pay lower rates and get additional tax breaks and benefits that aren't available in many other countries. In 2016, the EU's antitrust enforcer told Ireland to recoup the illegal subsidies given to the Cupertino company between 2003 and 2014, when the country began reforming its tax system.

In 2018, Apple handed Ireland 14.3 billion Euros ($16.7 billion) - the original amount specified plus interest – a decision CEO Tim Cook called "total political crap." The company appealed, and four years later it won when the General Court of the European Union said the EU failed to show Apple had gained an illegal economic advantage in Ireland by using the country's tax arrangements. The European Commission published a summary of how it planned to appeal a year later.

On Thursday, Giovanni Pitruzzella, advocate-general of the European Court of Justice, the EU's highest court, said that the previous decision to reverse the EU's order for Apple to pay back taxes in Ireland "should be set aside" and that the case should be referred back to the lower tribunal.

Pitruzzella said the General Court committed a series of errors in law and had also failed "to assess correctly the substance and consequences of certain methodological errors that, according to the Commission decision, vitiated the tax rulings."

"It is therefore necessary for the General Court to carry out a new assessment," Pitruzzella said.

While the opinions of advocates-general are non-binding, they often influential in final judgments by the EU's top court, writes the Financial Times.

Responding to the advocate-general's opinion, Apple said that the lower court "was very clear that Apple received no selective advantage and no State aid, and we believe that should be upheld."

Ireland maintains its position that it had not provided any state aid to Apple and that the company paid the correct amount of Irish tax.

An EU Court of Justice ruling is expected next year.