Ireland must recover up to 13 billion euros ($14.6 billion) in unpaid taxes from Apple, European officials said on Tuesday.
The tax ruling is the biggest the European Union has ever made regarding a single company, and it could spark a huge transatlantic row over how Europe treats U.S. companies.
Apple shares initially fell almost 3%, but then recovered most of their losses. The company will appeal the decision. It said the ruling upended the international tax system and would damage jobs and investment in Europe.
The European Commission, which administers EU law, said the Irish government had granted illegal state aid to Apple by helping the tech giant to artificially lower its tax bill for more than 20 years.
"[EU] member states cannot give tax benefits to selected companies -- this is illegal under EU state aid rules," said Commissioner Margrethe Vestager, Europe's top antitrust official.
The United States fired back immediately, saying retroactive tax assessments by the EU were unfair.
"The Commission's actions could threaten to undermine foreign investment, the business climate in Europe, and the important spirit of economic partnership between the U.S. and the EU," a Treasury spokesperson said.
The decision amounted to "a transfer of revenue from U.S. taxpayers to the EU," White House press secretary Josh Earnest said. The Obama administration would fight for "American taxpayers and American businesses overseas when they're being treated unfairly," he added.
Apple paid tax at 1%, or less, on profits attributed to its subsidiaries in Ireland, well below the 35% top rate of corporate tax in the United States and Ireland's 12.5% rate.
That prompted complaints by both European and U.S. lawmakers, who argued that Apple had been given an unfair advantage in exchange for creating jobs in Ireland. CEO Tim Cook was even called to testify on Apple's tax arrangements with Ireland before a Senate committee in 2013.
The bill for tax benefits, plus interest, covers 2003 to 2014. Apple has more than $231 billion in cash on its balance sheet to cushion the blow.
Cook said on Tuesday the ruling had "no basis in fact or in law," calling it "obvious targeting of Apple."
Apple had helped create and sustain more than 1.5 million jobs across Europe, follows the law and pays all the taxes it owes, he added.
"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," he wrote.
Ireland said it will appeal the decision, saying Apple paid what it owed. The country has one of the lowest corporate tax rates in Europe, which makes it an attractive place for global companies.
The Irish government is afraid companies would be less likely to invest in Ireland if its tax regime changes, which could cost the country thousands of jobs.
Apple is not the only American company that has recently found itself under scrutiny over its European tax affairs.
The European Commission ordered Starbucks and Fiat Chrysler to repay millions in taxes last October.
Starbucks has to pay back up to 30 million euros it saved thanks to a sweetheart tax deal with the Netherlands. Fiat Chrysler was ordered to repay a similar amount after a similar deal with Luxembourg.
Both companies have appealed the decisions.
The EU is also probing the tax arrangements of Amazon and McDonald's. Google is under investigation over its taxes in France and a couple of other European countries.
The ruling against Apple's tax deal comes despite a stern warning from the U.S. Treasury Department last week that it would consider "potential responses" if the Commission doesn't change course.