The European Union has ordered Amazon to pay €250 million ($293 million) after finding that it benefited from an illegal tax arrangement with Luxembourg.

"Luxembourg gave illegal tax benefits to Amazon. As a result, almost three quarters of Amazon's profits [in Europe] were not taxed," said Margrethe Vestager, Europe's top official in charge of competition policy.

Luxembourg must now recover the "illegal aid."

Amazon (AMZN) denied that it received special treatment from Luxembourg and said that it "paid tax in full accordance with both Luxembourg and international tax law."

"We will study the Commission's ruling and consider our legal options, including an appeal," it said in a statement.

The Commission ruled that Luxembourg unfairly helped Amazon for over eight years by allowing the company to essentially split into two. One part of Amazon was making money by selling stuff online, the other was a holding company collecting royalties on its brand.

Only the first company paid taxes in Europe. The second firm was a shell company with no employees, offices or business activities.

Vestager said the arrangement did not reflect economic reality and resulted in a much lower tax bill.

"Amazon was allowed to pay four times less tax than other local companies subject to the same national tax rules," Vestager said.

Luxembourg said Wednesday that it doesn't consider its arrangement with Amazon illegal. "Amazon has been taxed in accordance with the tax rules applicable at the relevant time," its government said in a statement.

The ruling puts Commission President Jean-Claude Juncker in an awkward position. He simultaneously held the positions of prime minister and finance chief in Luxembourg when the tax arrangement with Amazon was agreed.

He now leads the body that will enforce the Amazon ruling.

The Commission opened the investigation into Amazon's tax affairs in October 2014.

Related: EU hits Apple with $14.6 billion tax bill

Brussels has in recent years cracked down on tax loopholes across the EU, targeting a series of big multinationals and investigating whether they had received illegal state aid.

Apple was slapped by a huge tax bill in 2016, when the EU ordered Ireland to recover up to €13 billion ($15 billion) from the tech company.

In 2015, the Commission ruled that Fiat Chrysler (FCAU) and Starbucks (SBUX) owed €20 to €30 million ($23.5 to $35 million) in back taxes.

The Commission is also investigating the tax arrangements of McDonald's (MCD) in Luxembourg.