By Valentina Pop and Sam Schechner

Apple Inc. won a major battle with the European Union when the bloc's second-highest court on Wednesday sided with the U.S. company over a EUR13 billion ($14.8 billion) tax bill that EU antitrust officials had said the company owed to Ireland.

The decision was a rebuke to Margrethe Vestager, who is leading the charge at the European Commission to rein in alleged abuses by big tech companies including Apple, Alphabet Inc.'s Google, and Amazon.com Inc.

But Wednesday's setback may at the same time embolden Ms. Vestager and other EU leaders in their push to create new regulations for tech companies, because they already argue that existing rules are insufficient to bring big tech companies to heel in areas ranging from competition to taxes.

The case stems from a 2016 decision by the European Commission, the bloc's top antitrust enforcer, which said that Ireland must recoup EUR13 billion in allegedly unpaid taxes between 2003 and 2014, money the commission said constituted an illegal subsidy under the bloc's strict state-aid rules.

The General Court swept aside that reasoning, saying it annulled the decision because the commission had failed to meet the legal standards in showing that Apple was illegally given special treatment.

The 2016 decision against Apple was one of Ms. Vestager's first big broadsides against tech companies in her role running the EU's competition enforcement, earning her the nickname "tax lady" from President Trump. She later issued Google three fines totaling $9.4 billion, and launched formal antitrust probes into Amazon and Apple. She is now also responsible for tech regulation and is considering imposing a digital tax on tech giants.

After Wednesday's decision, Ms. Vestager said she would "carefully study the judgment and reflect on possible next steps" and vowed to continue investigations into national tax deals with corporations to establish whether they constitute illegal subsidies.

"The Commission stands fully behind the objective that all companies should pay their fair share of tax," she said, adding that if one EU government gives corporations tax benefits that aren't available to their rivals, "this harms fair competition in the EU."

In a September hearing at the General Court, Apple's lawyers said the commission's decision to call for the payment "defied reality and common sense" and Apple's CEO Tim Cook at the time slammed the decision as "total political crap."

The company however had parked the sum in an escrow account, pending adjudication in EU courts.

The commission can still challenge the Apple ruling at the bloc's top court, the European Court of Justice. In recent comments, however, Ms. Vestager pointed to the limitations of state-aid law in enforcing what she describes as "paying your fair share of tax."

The overturning of the Apple decision comes at a sensitive time in the battle over how much tax big tech companies should pay -- and where they should pay it. European countries and the U.S. are at an impasse in international talks on the topic, with Europeans pushing for rules that would make tech companies pay more levies where their customers are based, and Americans rejecting a system that doesn't apply to all companies.

Several countries, including France, have unilaterally imposed taxes on tech companies. EU leaders, including Ms. Vestager, have said the EU would do the same if there isn't progress at an international level by the end of this year.

Apple and Ireland on Wednesday applauded the annulment of the tax case. Ireland reiterated that it gave no special treatment to Apple, and said that the company had paid taxes according to "normal Irish taxation rules."

Apple said that it supports international talks over how countries should divide up taxation rights for multinational companies. "This case was not about how much tax we pay, but where we are required to pay it. We're proud to be the largest taxpayer in the world as we know the important role tax payments play in society," an Apple spokesman said.

Tax activists, however, said the decision reinforces their call for new rules.

"If we had a proper corporate tax system, we wouldn't need long court cases to find out whether it is legal for multinational corporations to pay less than 1 percent in taxes," said Tove Maria Ryding, of the European Network on Debt and Development, a grouping of nongovernmental organizations active in the field of debt and finance.

While the Apple tax case isn't legally related to other antitrust enforcement that Ms. Vestager is pursuing, Wednesday's decision may dent her reputation and cast doubts on the solidity of other cases. The commission is currently defending a similar taxation case against Amazon and three antitrust decisions against Google in court.

"Sometimes, the Commissioner for Competition would be well-advised to restrain her eagerness for catchy political headlines and instead prepare her cases more thoroughly, so that they can hold up in a court of law," said German center-right MEP Markus Ferber, who in 2016 backed the commission's decision against Apple. "High-profile decisions like these being overturned is quite the disservice to the cause of tax justice," he said.

The tax case overturned in Wednesday's ruling is based on a quirk of EU law aimed at creating a level playing field for companies across the bloc by forbidding governments from granting companies some types of state-aid.

It was Ms. Vestager's first major taxation case in a series she brought against Amazon.com, Starbucks Corp., Nike Inc., Fiat Chrysler Automobiles NV and Engie SA of France. So far, the General Court has sided with Starbucks in a taxation case but with the commission in its case against Fiat. Amazon in March had argued at the General Court that Ms. Vestager's 2017 order to pay Luxembourg $277 million in allegedly unpaid taxes was riddled with legal and factual errors.

Commission lawyers denied those allegations and said that neither Amazon nor Luxembourg was able to prove that they didn't get an unfair advantage from the tax deal.

A central issue in the Apple case was whether two Irish tax rulings granted to Apple in 1991 and 2007 gave a form of special treatment to the company, or whether they just reiterated an interpretation of Irish tax law as it was applied more generally.

Those rulings allowed two Irish-registered Apple units to attribute only a small sliver of some $130 billion in profit to Ireland in an 11-year period. The commission said all that revenue should be attributed to Ireland, but the Irish government and Apple say they split the profit reasonably, given that almost all of Apple's intellectual property is developed in the U.S., not Ireland.

In Wednesday's ruling, the General Court said that, despite the gaps in the contested tax rulings, the commission hadn't proven the Irish government granted a special advantage to Apple that was unavailable to other companies in Ireland.

The commission had argued in its decision that the rulings gave Apple a selective advantage because the iPhone maker and Ireland offered no specific evidence to justify how the profit was allocated. The EU also argued the rulings deviated from the "arm's-length principle," a standard for setting commercial conditions between units of the same company as if they were independent.

Ireland contended however that its tax rulings "did not depart from 'normal' taxation" because it had merely followed a portion of Irish tax code that says nonresident companies shouldn't pay income tax on profit that isn't generated in Ireland.

Separately, the commission on Wednesday laid out several plans on how to ensure fairer taxation across the bloc, including by increasing obligations for digital platforms to report where and what amounts of tax they are paying and by facilitating joint audits across jurisdictions in the EU. Legislative proposals under these plans will be put forward in autumn, pending approval of national governments and the European Parliament.

"On the issue of corporate taxation, this [Apple tax] ruling probably makes it more urgent and more clear, the need for corporate tax reform," said commission vice president in charge of economic affairs, Valdis Dombrovskis. "That will be something the commission will come forward [with] in our autumn package," he said.

Write to Valentina Pop at valentina.pop@wsj.com and Sam Schechner at sam.schechner@wsj.com