For years, the maker of iPhones got a sweetheart tax arrangement from Ireland to pay less than 1 per cent tax on its billions of dollars in profits across the world.
But this week, the EU's highest court ruled an appeal of a 2016 decision should be set aside, meaning Apple now owes the Irish government €13 billion ($21.5 billion) in tax, plus interest.
Ireland had joined Apple in arguing against the bill being enforced, but it now stands to invest the money into a sovereign wealth fund.
How did this play out, and could the same thing happen in Australia?
What was the tax arrangement?
Ireland has long been known as a tax haven for multi-national companies based on its low rate of corporate tax (12.5 per cent) in comparison to other European countries.
But an investigation by the EU Commission found that Apple was paying less than 1 per cent on its profits based on agreements made between the tech company and the Irish government.
The company had registered two Irish subsidiary companies responsible for Apple's EU, African, Middle Eastern and Asia-Pacific markets, through which profits flowed onward to the US parent company.
Since 1991, the Irish government had agreed to allow Apple to record most of its profits on products and services sold in the EU and elsewhere under a "head office" that was not subject to Irish tax rules, instead being effectively registered nowhere, according to the EU Commission.
Its motivation to offer Apple tax benefits was to encourage the company to base its European headquarters in Ireland.
The European Court of Justice on Tuesday upheld a 2016 ruling that Ireland had allowed Apple to avoid paying billions of euros in tax on the company's Irish profits through this set up.
The two-year investigation by the commission found the arrangement had allowed Apple to pay as little as 1 to 0.005 per cent in tax in some years on its profits between 2003 and 2014.
EU competition commissioner Margrethe Vestager, who had been prosecuting the case for eight years, called the court's decision a "huge win for European citizens and tax justice".
"The commission's investigation concluded that Ireland granted illegal tax benefits to Apple, which enabled it to pay substantially less tax than other businesses over many years," Ms Vestager said in 2016.
Crucially, both agreements were based on proposals from Apple as to how the tax arrangement should be carried out, and Ireland did not offer other companies the same deal, which Ms Vestager called "selective treatment".
In comparison, France charges a 25 per cent tax rate on corporate profits, with most European countries charging above 20 per cent.
Who were the parties to the case?
Interestingly, the Irish government had joined Apple to argue that the company should not pay tax on profits channelled through its Irish subsidiaries.
The court instead ruled that Ireland's tax laws need to be aligned with EU legislation.
Ireland's finance minister, Jack Chambers, said the agreement under which the "illegal benefits" had occurred was no longer active, and said the country's broader tax framework was aimed at encouraging investment and employment to Ireland.
"We understand that many do not believe that companies are paying the right amount of tax in the right places," Mr Chambers said.
"We have always said this type of issue can only be resolved globally through a stable global consensus for how and where companies should be taxed."
The minister said the government would carefully consider how to spend the back-paid revenue, part of which could go into Ireland's sovereign wealth fund.
In 2020, Apple placed the €13 billion in an escrow account pending its appeal, which will now be released to the Irish government.
The tech company, founded in 1976 by Steve Jobs and others, said it was disappointed with the court's decision.
"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," Apple said.
What do tech companies like Apple pay in Australia?
Australia's corporate tax rate is 30 per cent.
Apple brought in $9.33 billion in income from its Australian business in the 2021-22 financial year, according to the ATO.
But it was able to reduce that figure to $459 million for its taxable income, meaning it paid just $137.3 million in taxes.
This is a common occurrence. Facebook paid just $30.2 million in tax despite bringing in over $1.15 billion in income in the same financial period.
The ATO's corporate tax transparency report revealed last year that more than 800 large companies had paid no tax in 2021-22, same as the financial year preceding it.
Matt Grudnoff, a senior economist at the Australia Institute, said tech companies are able to reduce what they owe the ATO by doing what is termed "profit shifting".
"Basically what Apple and those big tech companies are really good at is shifting profits offshore, so Apple says that the stuff they sell in Australia is actually not where the value add is," Mr Grudnoff said.
"What they say is the bit that's most 'valuable', if you like, about Apple's goods and services, is the IP [intellectual property] — the research and development that goes into making products.
"A big chunk of it will be IP that they then pay to the parent company of Apple, which they treat as a completely separate entity."
So while profits are made in Australia by selling goods and services such as iPhones, the company's profit structure allows it to be taxed in Ireland at the 12.5 per cent rate rather than 30 per cent.
Facebook's parent company Meta also works on the same principles, Mr Grudnoff said, by arguing that their profits (by and large from advertising on the social media platform) lie not in their ad sales but in selling the IP to its parent company Meta, also registered in Ireland.
Successive governments have tried to crack down on this in different ways, including the news media bargaining code introduced by the Morrison government in 2021 to force companies such as Meta to pay for Australian news content on its platforms.
Meta announced it would no longer fund those deals earlier this year.
Mr Grudnoff said a range of other rules could stop the overseas profit transfer, including considering purchases between subsidiary companies, like in the case of IP, as a transfer to allow proper taxation of profits.
"The biggest problem is governments believe it's really hard to go alone — there's a strong sense that the world should move and have similar laws around this to stop it," he said.