Hungary's imposition of €3 million in penalties on Google Ireland for failure to register to pay an advertising tax was unfair and in violation of EU law, the European Court of Justice ruled Tuesday.

Imposing immediate, daily penalties on a non-Hungarian company constitutes "a difference in treatment" and "a restriction on the freedom to provide services" that violates Article 56 of the EU's founding treaty, Europe's highest court ruled.

The decision means that Google will not have to pay the fines for failing to register in 2017 to pay tax on sales of advertising in Hungary.

Google had appealed both the imposition of the tax and the fines, claiming that the tax unfairly penalized some companies because it was based on revenue, and that the fines were unfair because they were assessed immediately, with inadequate time for appeal.

Google also argued that Hungarian companies were not subject to the same fines, as they are automatically assessed taxes.

Hungary claimed that Google had attained a competitive advantage by not registering for taxes, and that the size of the fines was justified because the complaint dated back to 2015.

In its ruling Tuesday, the European Court of Justice upheld a lower-court ruling that Hungary was within its rights to require registration and impose penalties for non-compliance, and that the requirement in itself did not constitute an illegal restriction on providing services.

But it agreed with Google that the penalties for late payment were unfair because Hungarian companies were not subject to the same penalties, and that in practice only non-Hungarian companies were assessed on the penalties. The court also found that the size of the penalties was "disproportionate" and therefore "unjustified."

The ruling on penalties is in line with the view of the EU's competition commissioner, Margrethe Vestager, and with a non-binding opinion issued last autumn by an adviser to the Court of Justice. Advocate General Juliane Kokott wrote in September that the Hungarian advertising law had been applied unfairly to companies not based in Hungary, imposing "coercive measures" that constitute "an indirect restriction of the freedom to provide services."