London CNN Business  — 

Apple has won its appeal against a European Commission ruling that it owed Ireland €13 billion ($14.9 billion) in taxes.

The European Union’s second highest court ruled Wednesday that the Commission had not proven that the company had received illegal state aid from Ireland through favorable tax agreements.

The European Commission — Europe’s top antitrust authority — said in 2016 that the Irish government had granted Apple (AAPL) an illegal advantage by helping the iPhone maker keep its tax bill artificially low for more than 20 years.

But Ireland didn’t want the money. The small country became the European base for companies such as Apple, Google (GOOGL) and Facebook (FB) because it has one of the lowest corporate tax rates in Europe. So it teamed up with Apple to fight the Commission.

In a statement, an Apple spokesperson told CNN Business the company was “pleased” with the decision, arguing that the case was never about how much tax it pays, but where it pays it.

“We’re proud to be the largest taxpayer in the world as we know the important role tax payments play in society. Apple has paid more than $100 billion in corporate income taxes around the world in the last decade and tens of billions more in other taxes,” the spokesperson added.

Apple CEO Tim Cook has previously said the ruling had “no basis in fact or in law,” calling it “obvious targeting of Apple.”

The Irish government also welcomed the decision, saying it had never provided special treatment to Apple.

“The correct amount of Irish tax was charged taxation in line with normal Irish taxation rules,” the finance ministry said in a statement.

The court ruling is a major blow to the Commission, which has sought to crack down on what it considers unfair tax deals in Europe. The Commission could appeal the decision to Europe’s highest court.

Margrethe Vestager, the Commission’s top antitrust official, said she was carefully studying the judgment before deciding on next steps. But she vowed that the Commission would continue to aggressively pursue what it considers “illegal state aid.”

“At the same time, state aid enforcement needs to go hand in hand with a change in corporate philosophies and the right legislation to address loopholes and ensure transparency. We have made a lot of progress already at national, European and global levels, and we need to continue to work together to succeed,” Vestager said in a statement.

— James Frater contributed to this article.