scored a big victory against the IRS in a case related to its Luxembourg subsidiary that could have cost the company $1.5 billion.

Share story scored a big victory Thursday against the IRS in a case that the company says could have cost it about $1.5 billion.

The case is related to the creation more than a decade ago of Amazon’s European subsidiary in Luxembourg.

The ruling, in favor of Amazon, untangles part of the complex web of tax litigation the retailer faces as authorities in the U.S. and Europe review how they deal with global companies that straddle many jurisdictions seeking advantageous tax deals.

The European Commission is currently investigating the tax agreement Amazon struck with Luxembourg, to determine whether it gives the U.S. company unfair advantages.

Amazon declined to comment on Thursday’s U.S. Tax Court ruling. The Internal Revenue Service didn’t immediately respond to a request for comment.

The IRS contended that the e-commerce giant had inappropriately brought down its U.S. tax bill by grossly undervaluing the assets it transferred to its Luxembourg subsidiary.

Judge Albert Lauber of the U.S. Tax Court ruled that the IRS’ determination of those assets’ worth was “arbitrary, capricious, and unreasonable.” He also broadly sided with Amazon on the way the U.S. company calculates how it shares costs with its European subsidiary.

The case started in late 2012, when Amazon contested an IRS finding that it had underpaid its taxes by hundreds of millions of dollars. But its origins date to the creation in the mid-2000s of a European-wide subsidiary based in Luxembourg.

Before then, Amazon’s operations in the U.K., France and Germany operated as inefficient, independent units, and the company wanted to create an infrastructure that would support a European-wide fulfillment network and simplify tax issues.

Luxembourg was an attractive destination, offering a much lower tax rate than the U.S. So Amazon engaged in a complicated series of transactions, under the code name “Project Goldcrest” (Luxembourg’s national bird) to create a subsidiary there.

In 2005, Amazon’s newly born unit agreed to pay its U.S. parent $226.5 million over seven years for the use of its intellectual property. Another payment agreement, for $28 million, was struck in 2006. The subsidiary also agreed to enter a cost-sharing agreement with the U.S. company.

The IRS, however, determined that Amazon’s Luxembourg subsidiary should have paid its U.S. counterpart $3.6 billion (it later reduced that calculation to $3.5 billion).

The agency also contended that Amazon owed some $234 million in tax payments on its 2005 and 2006 bills, related to the income collected from its European subsidiary.

In securities filings, Amazon said that resulting adjustments would have meant an additional U.S. tax bill of $1.5 billion, plus interest.