Apple has been told it will not have to pay Ireland €13bn (£11.6bn) in back taxes after winning an appeal at the European Union's second-highest court.
It overturns a 2016 ruling which found the tech giant had been given illegal tax breaks by Dublin.
The EU's General Court said it had annulled that decision because there was not enough evidence to show Apple broke EU competition rules.
It is a blow for the European Commission, which brought the case.
However, it has 14 days to appeal against the decision at the EU's supreme court, the European Court of Justice.
What has the reaction been?
"This case was not about how much tax we pay, but where we are required to pay it," Apple said in a statement. "We're proud to be the largest taxpayer in the world, as we know the important role tax payments play in society."
The Irish government - which had also appealed against the ruling - said it had "always been clear" Apple received no special treatment.
"The correct amount of Irish tax was charged... in line with normal Irish taxation rules."
EU Competition Commissioner Margrethe Vestager, who brought the case, said she would "study the judgment and reflect on possible next steps".
Dutch MEP Paul Tang called the ruling "deeply unfair".
"I suspect that many people in Ireland think... 'Why is there a company that pays 0.05% in taxes?' I pay more taxes than Apple, for that matter. Many people pay more taxes."
What was Apple accused of?
The European Commission brought the action after claiming Ireland had allowed Apple to attribute nearly all its EU earnings to an Irish head office that existed only on paper, thereby avoiding paying tax on EU revenues.
The commission said this constituted illegal aid given to Apple by the Irish state.
But the Irish government argued that Apple should not have to repay the back taxes, deeming that its loss was worth it to make the country an attractive home for large companies.
Ireland - which has one of the lowest corporate tax rates in the EU - is Apple's base for Europe, the Middle East and Africa.
In Wednesday's ruling, the Luxembourg-based General Court sided with that position, saying there was not enough evidence to show Apple had received illegal state aid or minimised its tax bill.
What does this mean for Ireland?
One rather curious feature of this case is that if the ruling had gone the other way, and Ireland had been on the losing side, its "punishment" for breaching EU law would have been to receive a large amount of money: taxes the Commission said were owed by Apple.
That did not happen, so the ruling - subject to any appeal - means Apple doesn't in law owe the money, so Ireland won't get it.
In some quarters of Ireland, there will be relief that an agreement that helped encourage Apple to invest has not been overturned after the event.
But the sentiment is far from universal. A Sinn Féin spokesman called it a bad day for the Irish taxpayer that would draw negative attention to the country's international tax reputation.
What about other big tax avoidance cases?
There is growing criticism of so-called sweetheart tax deals across the European Union and the bloc has been trying to clamp down.
The ruling will therefore be a blow to Ms Vestager, who has taken aim at a host of big corporations over their allegedly anti-competitive practices.
Last year, she lost a case against Starbucks, which was accused of owing €30m in back taxes to the Netherlands. Rulings on Ikea and Nike's tax arrangements in that country are due soon.
Jason Collins, partner and head of tax at law firm Pinsent Masons, said: "Apple's victory shows that European courts are unwilling to call beneficial tax regimes state aid, even when designed to attract foreign investment - provided they apply the rules consistently.
"This will be a very welcome outcome for other multinationals who have been watching this case closely."
However, he said Brussels was likely to appeal and EU efforts to tackle tax avoidance would continue.
"We expect the EU to continue applying pressure in this area," he said.