The Commission says that because the deal gave Apple a "significant advantage" over its competition, the iPhone maker must now be prepared to pay back "illegal state aid" over the ten-year period before it began investigating its tax practices. Officials say that amount totals around €13 billion (from between 2003 and 2014) and that interest must also be accounted for. That could mean an additional €1-2 billion could be bolted onto that figure.

"Member States cannot give tax benefits to selected companies – this is illegal under EU state aid rules. 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," says Commissioner Margrethe Vestager. "In fact, this selective treatment allowed Apple to pay an effective corporate tax rate of 1 percent on its European profits in 2003 down to 0.005 percent in 2014."

Apple and the Irish government will appeal the ruling. The company said the following in a statement:

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. The Commission's case is not about how much Apple pays in taxes, it's about which government collects the money. It will have a profound and harmful effect on investment and job creation in Europe. Apple follows the law and pays all of the taxes we owe wherever we operate. We will appeal and we are confident the decision will be overturned.

The story began way back in 1991 when Apple signed a deal with the Irish government that enabled it to use a very specific type of tax loophole. This loophole was called a "double Irish" and, very simply, allowed Apple to split profits, paying almost nothing in the process. It's quite a successful system, and in 2014, Apple was able to stash two-thirds of its global income in this tax haven. While Apple is feeling the effects of the ruling, it was Ireland that arranged the illegal deal.

It's not just Europe that feels that Apple's tax affairs were shady, with Senator Carl Levin criticizing the company back in 2013. He wrote a lengthy report (.PDF) saying that Apple had negotiated an effective tax rate of less than two percent in Ireland. In the US, by comparison, it would have been expected to at least pay 15 percent.

But sweetheart deals are in violation with the principles of the free market, which the European Commission has sought to uphold. Countries are barred from offering secret handouts to give local players an unfair advantage over the competition. This is classified as "state aid," and is illegal in the eyes of the Commission.

In response to the ruling, Apple posted a Customer Letter titled "A Message to the Apple Community in Europe" to its website, in which Apple CEO Tim Cook detailed the company's investment and growing operations in Ireland. He also took time to comment on the ruling and how it may affect EU businesses doing business in the US:

"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. 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."

"Beyond the obvious targeting of Apple, the most profound and harmful effect of this ruling will be on investment and job creation in Europe. Using the Commission's theory, every company in Ireland and across Europe is suddenly at risk of being subjected to taxes under laws that never existed."

The US won't agree with the ruling, given that it feels that any tax Apple owes should go to the treasury. Tim Cook himself has said that he feels that where you "create value is the place where you are taxed." The implication being that the only place Apple should be on the hook for tax is in the US, even though much of that value is created in Foxconn's Chinese factories. But, then again, it's not as if the US currently benefits from Apple's largesse, either.

The company has been very open about the fact that it has roughly $230 billion stashed in overseas bank accounts that it refuses to repatriate. Cook justifies this by saying that the cost of returning money to the US is too high -- shaking out to a tax rate of almost 40 percent, or $92 billion. An investigation over at Forbes revealed that Apple recently hired a Washington lobby firm to push for a corporate tax holiday, even though such a program has been proven not to work.

Daniel Cooper contributed to this report.