Ireland is waking up to a legal and moral quagmire over the Apple tax bill.
The big question is this: will Ireland appeal the decision, and what are its chances of winning, whatever about the political fallout from turning down €13 billion from Apple?
RTÉ's Europe Editor Tony Connelly looks at the Apple ruling and the possible impact of a similar case involving Spanish bank Santander.
The Government has already been sharpening the axe with some of the most stridently anti-Brussels rhetoric ever heard in Dublin, more aggressive even than that heard in the dark days of the Troika.
The refrain is that the Commission is mis-using state aid rules to ride roughshod over Ireland's corporate tax system, something the Government has jealously guarded as a national competence for years.
Those who fulminate that the Commission's ruling is an unacceptable interference in our sovereign tax affairs, however, are missing a very important point.
The Commission's powerful anti-trust arm has been investigating breaches of state aid rules through tax benefits for decades, and European jurisprudence is littered with cases on the matter, which have gone through the European Court of Justice (ECJ).
Commissioner Margrethe Vestager told a news conference on Thursday: "We have a court practice that says quite clearly that state aid can come in many forms.
"In this case [it's] as a tax benefit . . . The only politics of that is that we're here to make sure the [EU] Treaty is upheld and this is in the Treaty."
In other words, the Commission argues that this is not political. A tax benefit is just the same as any other benefit that might be advantageous to one company and not another.
And the Treaty obliges the Commission to act.
The key part of that Treaty is Article 107 (1). It says the following:
"Any aid granted by a Member State … which distorts or threatens to distort competition by favouring certain undertakings or the production of certain goods shall, in so far as it affects trade between Member States, be incompatible with the internal market."
The task facing the Irish Government is to prove that the deal allegedly allowing Apple to avoid tax to the tune of €13 billion was NOT something which only favoured Apple as a company, or favoured the way it does business, to the detriment of other companies.
While Article 107 (1) may appear straightforward, its application in practice, and its interpretation in numerous legal cases to date, is very complex.
Such cases have normally been the arcane preserve of tax lawyers, academics and competition experts. While many have flowed through the courts, they have rarely attracted mainstream attention - until now.
Let's take one obscure case relating to a number of Spanish companies in 2005, one which could have a powerful - perhaps pivotal - impact on Ireland's prospects of winning an appeal against the Commission's decision.
In 2005 a number of Spanish firms contacted their MEPs to complain about a particular provision in the Spanish tax code.
The provision allowed Spanish companies, which had shareholdings of up to 5% in foreign companies, to effectively offset some of the resulting tax-related expenses connected to those shareholdings against their domestic tax liabilities.
The Spanish firms who complained were upset, because it only seemed to benefit rival firms which had foreign shareholdings, and not companies which operated in Spain only.
In October 2007, as a result of the complaints, the European Commission's competition arm opened an investigation to see if the scheme breached state aid rules.
Remember, this is long before Apple's tax affairs had raised any eyebrows.
The Commission concluded that the scheme in Spain did, indeed, confer an unfair advantage to one category of company over another. Spain was ordered to recover the aid granted under the scheme, just as the Irish Government is this week being ordered to recover the Apple tax revenues.
However, three Spanish companies which availed of the scheme were not happy with the Commission's decision.
The companies were Santander Bank, a financial services company called Santusa, and the motorway service station chain Autogrill.
In 2010, the three companies appealed the Commission's state aid decision to the General Court of the European Court of Justice in Luxembourg.
This is also where Ireland's appeal will go.
On 7 November 2014, the General Court found in the companies' favour and rejected the Commission's conclusion that the scheme amounted to illegal state aid.
The reason the General Court found in their favour was based on the nature of how state aid is defined.
This will be absolutely critical in the Irish case.
For a tax concession, such as that given to Apple, to qualify as illegal state aid, four criteria must be fulfilled.
* The aid must be provided by the state and financed by state resources.
* It must grant an advantage.
* The advantage must be selective - i.e., it goes to one company, or one category of companies with a specific commercial activity, and not to others.
* Finally, it must distort competition and trade within the EU.
The third criterion is the key one, selectivity.
In the case of Santander, Santusa and Autogrill, the General Court ruled that the Commission hadn't proved that the scheme selectively benefitted some companies over others.
It argued that the concession under Spain’s tax code was theoretically available to anyone, so therefore it wasn’t selective.
While the Commission had argued that EU law meant that a particular category of company couldn’t avail of a scheme if others didn’t enjoy the same advantage, the General Court ruled that - in the Santander situation - it did not involve a particular category of companies, but a particular category of economic transactions, i.e., those which related to having a 5% shareholding in a foreign company.
This was a pretty nuanced, but very important distinction.
In another case that went to the ECJ, involving a Hungarian oil and gas company called MOL, judges ruled that even if only one company benefitted from the tax scheme in question, it didn't necessarily mean it was selective.
But the legal tussle over the Santander case didn't end in November 2014.
The European Commission appealed the General Court judgment, which meant the issue went up to the European Court of Justice itself.
Essentially, the Commission argued that the General Court was wrong in the way it interpreted European law in how it addressed the selectivity issue.
Specifically the Commission argued that the General Court was too restrictive in how it addressed the issue of how you identified a category of companies.
Few people outside Spain's corporate sector would have paid any attention to these complex, legalistic goings on in the sombre environs of the Luxembourg court buildings.
But some were.
Outside of Spain, only two EU member states sent lawyers to make detailed written and oral submissions to the hearing.
One was Germany. The other was Ireland.
Ireland made several significant contributions to the hearings when they took place in Luxembourg.
In fact, the Santander case had been regarded with intense interest by Dublin for at least a year, and probably dating back to the point at which the European Commission appealed the General Court decision which would have been some time in late 2014 - i.e., the same year that Brussels had issued its preliminary negative finding against Ireland and Apple.
The Irish Attorney General, the Revenue Commissioners and the Department of Finance jointly recommended to the Government that Ireland intervene in the Santander case.
The State engaged a senior counsel, specialised in EU law, to make submissions on Ireland’s behalf.
There's no doubt why Ireland was taking such a big interest in this case.
Officials knew that the exact same issues and controversies would be at play in the Apple case - if and when it exploded.
Not surprisingly, Ireland's intervention came down on the side of Santander, and not the Commission.
Ireland backed the argument that the measure allowing companies with a 5% shareholding in foreign company did not mean that those companies were being benefitted selectively, because the scheme was theoretically open to anyone.
Ireland also argued that it was pretty impossible to determine, before the event, what categories of company would, or would not, be able to avail of such a tax concession.
Lawyers representing Santander also believed there was a fatal flaw in the Commission's argument.
The Commission was on record as saying that tax rulings per se were not illegal, nor did they necessarily amount to state aid.
In the Santander case, the Commission appeared to be saying that all companies - whether they were multinationals with several subsidiaries operating in different member states, or those operating only on the national territory - should be treated the same when it came to tax law.
Santander's lawyers argued that multinational companies are different.
They have to work out how to be taxed when products and services are being bought and sold across borders between their subsidiaries, a concept known as Transfer Pricing.
That meant that they should be differentiated when it came to how they were assessed for tax, and that this was why tax rulings - or letters of comfort - were vital.
They argued that the Commission was contradicting itself by not objecting to tax rulings on the one hand, and, on the other, saying that all companies - multinational and national - should be regarded in the same way.
Writing in a competition law blog, the partner of a Spanish law firm closely associated with the Santander case declared: "The implication of this approach is that virtually any tax ruling setting a transfer price would necessarily result in an apparent privilege to multinationals.
"However, that would contradict the premise underlying the Commission's reasoning that the general system of tax rulings is not objectionable."
In other words, they regard the Commission as interpreting selectivity according to some "ideal model", rather than comparing the tax ruling to the normal activity of the state.
This, they argue, means the Commission is stretching the boundaries of state aid rules.
So, getting back to the Apple case.
How important will the selectivity issue be? Will this be the main grounds for appeal by the Irish Government if and when it decides to challenge the Commission's €13 billion decision?
Experts believe that the appeal will be won or lost over this complex, yet critical issue.
Ireland can't simply argue that the Commission has no jurisdiction over Irish tax law, when clearly, according to numerous cases dating back decades, the Commission has been fully within its rights to explore whether a tax benefit to one company, and not to others, gives it an unfair advantage, and therefore qualifies as illegal state aid.
The Government could also argue that under Irish tax law, there no such things as "tax rulings".
There are simply opinions which the Revenue Commissioners provide, which only become "rulings" according to a court judgment.
But the biggest hint that Ireland will have to rely heavily on the selectivity issue can be found in the highly publicised attack by the US Treasury Department on the Commission's investigation into Apple.
In that white paper the Treasury Department refers time and again to the issue of selectivity, accusing Commissioner Vestager of repeatedly going against European case law in the way she is interpreting it in the Apple case.
It's clear that whoever wrote the Treasury report had spent time wading through the Santander cases and others.
And in every other respect, the attack by the Treasury paper has almost been identical to the attack on the Commission launched by the Irish Government, and Apple.
While the Commission has been explicit in spelling out the huge amounts of profits Apple earned and the little tax allegedly paid, it has yet to spell out how exactly the selectivity criterion was applied.
On Thursday, Commissioner Vestager was asked about whether the tax ruling for Apple was selective, and how that concept of selectivity was being interpreted in this case.
She replied: "Tax rulings are by nature selective, because they're [between] the company and the tax authority. They have this relationship as one to one.
"It depends on the type of tax ruling … When the tax rulings provide a methodology then they are typically very, very specific to a certain company.
"And that is of course the thing here."
One source said that establishing selectivity was, despite the squabbles in the ECJ, "straightforward."
"The Court of Justice has confirmed that in the case of an individual aid measure the finding of an advantage is sufficient to support the presumption that it is selective," the source said.
The source insisted that the measure being assessed in the Irish decision is a tax ruling granted to Apple, "which can only be used by Apple. It is specific to the operations of Apple in Ireland and the structure of Apple Sales International and Apple Operations Europe."
However, exactly how the methodology of Apple's tax arrangements, as agreed in 1991 and 2007, worked in detail remains unknown.
That is because the full, 130-page report into Apple cannot be published for several months while confidentiality concerns (mainly the company's, according to the Commission) are dealt with through the redaction process.
But the battles at the European Court of Justice on the issue were subject to one more dramatic twist on 28 July last.
Despite the interventions by Santander - and Ireland - the European Court of Justice Advocate General, during the appeal by the Commission against the General Court's decision, issued a legal opinion on the matter at hand.
The Advocate General, Belgian judge Melchior Wathelet, rejected the General Court's ruling which had overturned the Commission's case against Santander.
This meant he agreed with the Commission's interpretation of selectivity, and disagreed with Santander's (and Ireland's) interpretation.
Here's a relatively clear analysis by tax consultants KPMG on the dramatic development.
"The Advocate General noted that the fact that such a measure is available to a large number of taxpayers, or that the conditions to benefit from it are easy to fulfill, does not call into question its selective nature but only the degree of selectivity.
"In the case at hand, the AG concluded that undertakings taxable in Spain and that acquire shareholdings in a foreign company on the one hand, and in a domestic company on the other hand, are in a comparable situation.
"As a consequence, the Spanish aid is selective, since it benefits undertakings performing cross-border transactions, but not undertakings performing the same transactions at the national level."
It's important to stress that this is only a legal opinion. The full judgment on the Santander case will probably take another few months.
But in 80% of cases, the final judgment in ECJ rulings concur with the Advocate General’s opinion.
This means the Irish Government faces a cliffhanger.
Dublin is likely to appeal the Commission's decision, and it is almost certain that it will rely heavily on existing case law to argue that what was provided to Apple was, strictly speaking, not selective, as the concept is understood in state aid law.
As one observer put it, the Commission would have to show that it had done due diligence and proved that lots of other companies in Ireland, whether multinational or not, could not have availed of a similar tax deal.
If the final judgment in the Santander case - which will probably come out after the Government jumps - declares that the Commission's definition of selectivity is the correct legal one, then that judgment would trump all other European case law.
That would make Ireland’s appeal very difficult to win, according to several experts.
Would it make it impossible?
That is the €13 billion question…
Analysis: Europe Editor Tony Connelly