(This September 19 story corrects to read Gracia, paragraph 13)

BRUSSELS (Reuters) - McDonald's MCD.N avoided having to repay millions of euros in back taxes after EU antitrust regulators said that its tax deal with Luxembourg was not illegal, citing quirks in the Grand Duchy's bilateral tax treaty with the United States.

The decision by the European Commission came after a three-year long investigation, part of its crackdown on illegal sweetheart deals between EU governments and multinationals that has resulted in Apple AAPL.O, Starbucks SBUX.O and Fiat FCHA.MI paying billions of euros in back taxes.

The Commission said McDonald’s tax deal was in line with national tax laws and the Luxembourg-U.S. double taxation treaty.

“Our in-depth investigation has shown that the reason for double non-taxation in this case is a mismatch between Luxembourg and U.S. tax laws, and not a special treatment by Luxembourg. Therefore, Luxembourg did not break EU state aid rules,” European Competition Commissioner Margrethe Vestager said.

“Of course, the fact remains that McDonald’s did not pay any taxes on these profits – and this is not how it should be from a tax fairness point of view,” she said.

The investigation had focused on McDonald’s Luxembourg-based subsidiary Europe Franchising which receives royalties from franchisees in Europe, Ukraine and Russia.

Slideshow ( 3 images )

Luxembourg in a 2009 tax ruling said the company did not have to pay corporate taxes as its profits would be taxed in the United States. In a second tax ruling, the Grand Duchy said that the company was no longer required to prove that its royalty income was subject to U.S. taxation.

“HAPPY MEAL”

The Commission said 70 companies benefited from the bilateral tax treaty but were not being investigated. In June this year, Luxembourg presented draft legislation to avoid double non-taxation.

Luxembourg said in a statement that it welcomed the Commission's recognition of the steps it had taken to avoid similar cases in future. It had been ordered to claw back millions from Engie ENGIE.PA, Amazon AMZN.O and Fiat FCHA.MI in the last three years.

“We pay the taxes that are owed and, from 2013-2017, McDonald’s companies paid more than $3 billion just in corporate income taxes in the European Union with an average tax rate approaching 29 percent,” McDonald’s said. “We will continue to invest in Europe and expect to create 50,000 new jobs over the next four years.”

Sven Giegold, a Greens lawmaker at the European Parliament who has been pushing for more action to tackle tax loopholes, criticized the EU decision.

“Luxembourg and other EU countries are serving McDonald´s a happy meal with tax loopholes, and taxpayers must pay the bill,” said Giegold.

The ruling is a recognition by enforcers that they cannot make unlimited use of their state aid powers on taxation issues, said Natura Gracia, a partner at law firm Linklaters.

“This is a welcome development given the wider context of other state aid investigations into tax rulings and will give some comfort to companies which have obtained similar tax rulings in Luxembourg or elsewhere in the EU,” she said.