In a letter to customers, Apple CEO Tim Cook insisted that the company has followed all international laws and would fight a ruling by the European Commission that it owes $14.5 billion to the government of Ireland.

“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,” Cook wrote. “The opinion issued on August 30th alleges that Ireland gave Apple a special deal on our taxes. This claim has no basis in fact or in law. We never asked for, nor did we receive, any special deals. We now find ourselves in the unusual position of being ordered to retroactively pay additional taxes to a government that says we don’t owe them any more than we’ve already paid.”

On Tuesday, the EC ruled that Apple had created a phony shell company to which it assigned the vast majority of its international profits in order to massively reduce its tax bill. The EC said the scheme gave Apple an unfair advantage and stated that the $14.5 billion is taxes the companies owes, rather than a penalty.

In defending Apple, Cook reached back into history to note that Ireland was the site of one of Apple’s first international operations back in 1980. Not only does Apple now have 6,000 employees in Ireland, he said, but Apple’s presence has attracted many other international companies to boost the Irish economy.

Apple has created more than 1.5 million jobs in Europe, Cook wrote, counting its own employees and app store developers and its suppliers and manufacturers. What’s more, Apple says it’s the largest tax payer in Ireland, the U.S., and on the entire planet.

“The Commission’s move is unprecedented and it has serious, wide-reaching implications,” Cook wrote. “It is effectively proposing to replace Irish tax laws with a view of what the Commission thinks the law should have been. This would strike a devastating blow to the sovereignty of EU member states over their own tax matters, and to the principle of certainty of law in Europe. Ireland has said they plan to appeal the Commission’s ruling and Apple will do the same. We are confident that the Commission’s order will be reversed.”

On the specifics of the EC’s accusations, Cook said that what matters is not where sales are generated, but “where the value is created.” For Apple, that value is created in the U.S., he wrote.

“In Apple’s case, nearly all of our research and development takes place in California, so the vast majority of our profits are taxed in the United States,” he wrote. “European companies doing business in the U.S. are taxed according to the same principle. But the Commission is now calling to retroactively change those rules.”

Cook said Apple would continue to invest in Ireland, and he repeated previous calls he has made for tax reform.

Meanwhile, singing a similar tune, Irish finance minister Michael Noonan told the BBC in a statement:

I disagree profoundly with the Commission. The decision leaves me with no choice but to seek cabinet approval to appeal. This is necessary to defend the integrity of our tax system; to provide tax certainty to business; and to challenge the encroachment of EU state aid rules into the sovereign member state competence of taxation.

Over on Twitter, where #AppleTax was trending, Irish residents expressed some annoyance that their government was fighting a decision that, in theory, could put a huge sum of money back into the national treasury. The Irish economy has been struggling, and government cutbacks have left some frustrated about the national austerity regime.