The European Commission ruling is part of a drive against sweetheart tax deals that smaller states in the bloc offer multinational companies to lure jobs and investment.
The European Commission has ordered Apple to pay Ireland unpaid taxes of up to $14.5 billion as it ruled the firm had received illegal state aid.
Ireland opposed the decision since it uses lower tax to attract investment from multinational companies.
Apple and Dublin said the US company's tax treatment was in line with Irish and European Union law and they would appeal the ruling.
The European Commission ruling is part of a drive against what the EU says are sweetheart tax deals that usually smaller states in the bloc offer multinational companies to lure jobs and investment.
The US feels its firms are being targeted by the EU and a US Treasury spokesperson warned the move threatens to undermine US investment in Europe and "the important spirit of economic partnership between the US and the EU."
Starbucks has been ordered to pay up to $33 million to the Dutch state, while Amazon.com and McDonald's are also under investigation by the Commission, the EU's executive arm.
EU Competition Commissioner Margrethe Vestager questioned how anyone might think an arrangement that allowed Apple to pay a tax rate of 0.005 percent, as Apple's main Irish unit did in 2014, was fair.
"Tax rulings granted by Ireland have artificially reduced Apple's tax burden for over two decades, in breach of the EU state aid rules. Apple now has to repay the benefits," Vestager told a news conference.
Apple, which had more than $200 billion in cash and readily marketable securities at the end of June, is likely to see the case drag out for years in EU and possibly Irish courts.
The EU's ruling challenges the way that Ireland agreed to tax the profits of Irish-registered Apple subsidiaries, through which most of its non-US profits flowed.
Apple licenses the rights to technology designed in the United States to Irish subsidiaries. These then hire contract manufacturers to make devices which they sell to Apple retail subsidiaries around Europe and Asia.
Since the manufacturing cost is a small portion of device sales prices and retail subsidiaries are allocated a small operating margin, Apple Ireland is very profitable.
In 2011, it earned $22 billion after paying $2 billion to its US parent in relation to the rights to Apple intellectual property.
However, the Irish tax authority agreed only 50 million euros of this was taxable in Ireland, the European Commission said.
Irish Finance Minister Michael Noonan said he profoundly disagreed with the decision and in order to preserve Ireland's attractiveness for investment he would appeal.
"There is no economic basis for this decision. It's bizarre and it's an exercise in politics by the Competition Commission," Noonan said.
Ireland's low corporate tax rate has been a cornerstone of the country's economic policy for decades, drawing investors from multinational companies whose staff account for almost one in 10 of the country's workers.
For many technology firms like Google and Facebook, a key attraction is that Ireland allows companies to adopt tax structures which see them pay much less than the 12.5 percent headline rate. The companies say they follow all tax rules.
Apple said it was confident of winning an appeal.
"The European Commission has launched an effort to rewrite Apple's history in Europe, ignore Ireland's tax laws and upend the international tax system in the process," CEO Tim Cook said in a letter to customers posted on Apple's website.
"A company's profits should be taxed in the country where the value is created," he added.
Meanwhile, Turkey's Deputy Prime Minister Mehmet Şimşek created some stir on social media when he asked Apple to relocate to Turkey where it would receive even more generous tax incentives.
Apple should move to Turkey. Happy to provide more generous tax incentives. Won't have to deal with EU bureaucracyhttps://t.co/9ceOnauGi0— Mehmet Simsek (@memetsimsek) August 30, 2016