Apple and the Irish government have won their appeal against the European Commission over a €13 billion tax bill.
The General Court in Luxembourg annulled the decision taken by the commission over Irish tax rulings in favour of the tech giant.
The commission previously said the tech giant paid an effective corporate tax rate of just 1% on profits from sales made across the EU by routing them through a firm based in Ireland.
The commission said this constituted illegal aid given to Apple by the Irish state.
However, in its judgment the General Court stated that the commission was "wrong" to declare that Apple Sales International (ASI) and Apple Operations Europe (AOE) had been granted a selective economic advantage and, by extension, state aid.
The court ruled that the commission did not succeed in showing to the "requisite legal standard" that there was an advantage.
In its ruling, it said: "The General Court considers that the Commission incorrectly concluded, in its primary line of reasoning, that the Irish tax authorities had granted ASI and AOE an advantage as a result of not having allocated the Apple Group intellectual property licences held by ASI and AOE, and consequently, all of ASI and AOE trading income obtained from the Apple Group's sales outside North and South America, to their Irish branches.
"The General Court considers that the Commission did not succeed in demonstrating, in its subsidy line of reasoning, methodological errors in the contested tax rulings which would have led to a reduction in ASI and AOE's chargeable profits in Ireland.
"Although the General Court regrets the incomplete and occasionally inconsistent nature of the contested tax rulings, the defects identified by the Commission are not, in themselves, sufficient to prove the existence of an advantage."
The Commission can appeal against the General Court's decision to the European Court of Justice. The appeal must be made within the next two months and ten days.
The €13.1 billion is being held in an escrow account, meaning the proceeds cannot be released until there has been a final determination in the European courts over the validity of the commission's decision.
Ireland's open economy is based on low corporate taxation and other incentives to attract multinationals.
In Apple's case, it was significantly below the standard 12.5% imposed on corporations.
Apple said that from 2003 to 2014, it paid $577 million in tax on profit generated in the country, in line with the tax laws in Ireland.
The government opposes any effort to force it to change its taxation practices, which have tempted some of the world's leading financial and technology firms to set up base in Dublin.
In a statement, Ireland's Department of Finance said it welcomed the judgment: "Ireland has always been clear that there was no special treatment provided to the two Apple companies - ASI and AOE.
"The correct amount of Irish tax was charged taxation in line with normal Irish taxation rules.
"Ireland appealed the commission decision on the basis that Ireland granted no state aid, and the decision today from the court supports that view."