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 follows a record ruling by the European Commission against the US tech giant in 2016.
The EU’s General Court said it had annulled that decision because the Commission had not proved that Apple had broken competition rules.
It is a blow to the EU which is trying to clamp down on alleged tax avoidance.
However, it has the right to lodge an appeal at Europe’s highest court, the European Court of Justice, within 14 days.
“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”.
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.
The case is one example of a wider issue about whether multinational companies pay as much tax as they should. The ruling is a setback for those who say they should pay more.
But efforts among governments to agree new ground rules continue, while some, including Britain, are taking unilateral steps to get more tax from some of the big technology companies.
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.
However, 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.
The ruling could spell bad news for Ms Vestager, who has spent much of her time in office campaigning against tax schemes she argued were anti-competitive.
Last year she lost a case against Starbucks, which was accused of owing €30m in back taxes to the Netherlands. Rulings over Ikea and Nike’s tax arrangements in that country are also 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 multi-nationals 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.