Apple has been ordered to pay Ireland €13bn (£11bn; $14bn) in unpaid taxes by Europe's top court, putting an end to an eight-year row.
The European Commission accused Ireland of giving Apple illegal tax advantages in 2016, but Ireland has consistently argued against the need for the tax to be paid.
The Irish government said it would respect the ruling.
Apple said it was disappointed with the decision and accused the European Commission of "trying to retroactively change the rules".
A separate European Court of Justice (ECJ) ruling on Tuesday also brought a long-running case with Google to a close, with the company ordered to pay a €2.4bn (£2bn) fine for market dominance abuse.
The EU antitrust chief Margrethe Vestager praised both judgements. "Today is a huge win for European citizens and tax justice," she said.
In the Apple case, the ECJ said: "The Court of Justice gives final judgment in the matter and confirms the European Commission’s 2016 decision: Ireland granted Apple unlawful aid which Ireland is required to recover."
The ruling puts an end to a lengthy back and forth legal process.
The original decision covered the period from 1991 to 2014, and related to the way in which profits generated by two Apple subsidiaries based in Ireland were treated for tax purposes.
Those tax arrangements were deemed to be illegal because other companies were not able to obtain the same advantages.
That ruling came at a time when the Commission was attempting to clamp down on multinational giants it believed were using creative financial arrangements to reduce their tax bills.
It was overturned by the lower court of the ECJ in 2020 following an appeal by Ireland.
However, that verdict has now been set aside by the higher court, which said it contained legal errors.
Apple said in a statement: "This case has never been about how much tax we pay, but which government we are required to pay it to. We always pay all the taxes we owe wherever we operate and there has never been a special deal.
"The European Commission is trying to retroactively change the rules and ignore that, as required by international tax law, our income was already subject to taxes in the US.
"We are disappointed with today’s decision as previously the General Court reviewed the facts and categorically annulled this case," Apple added.
The bad news for Apple comes a day after the tech giant released its new iPhone 16 range.
The ECJ ruling means Ireland will have to recover the lost taxes from Apple – something Dublin has spent years of legal wrangling trying to avoid.
The Irish government has 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.
Although corporation tax rates for businesses are set nationally, and are not subject to the EU's jurisdiction, the trade bloc does have extensive powers to regulate state aid and in this case, it argued that by applying very low tax rates to Apple, Ireland was granting it an unfair subsidy.
The latest decision is a colossal victory for the European Commission in its attempts to stop big companies bending the rules.
The Irish government said the issue in the Apple case was "now of historical relevance only" and said the process of transferring assets to Ireland would now begin.
Tove Maria Ryding from the European Network on Debt and Development, an association of trade unions and non-governmental organisations, welcomed the ECJ's decision but stressed "our tax problem is more than just one rotten apple".
She said the case addressed tax matters dating back over 20 years and was "a perfect illustration of the chaotic corporate tax system we have".
“What we urgently need is a fundamental reform that can give us a tax system that is fair, effective, transparent and predictable," she said.
Europe's top court has also ruled that Google must pay a €2.4bn fine for abusing the market dominance of its shopping comparison service.
The tech giant had been appealing against the fine, which was originally levied by the European Commission in 2017.
Google said it was disappointed with the ruling, and pointed out it had made changes in 2017 to comply with the Commission's decision.
At the time it was the largest penalty the Commission had ever levied - though a year later it issued Google with an even bigger fine of €4.3bn over claims it used Android software to unfairly promote its own apps.