The European Court of Justice has ruled that Spain breached competition law when it insisted last year that mergers in its energy sector must be pre-approved by its regulator.

The Spanish government had argued that its aim was to safeguard public interest and security of supply when it imposed special conditions on the attempted takeover of Endesa by German power company E.On.

E.On subsequently withdrew its bid for the Spanish energy group, which was later bought by Acciona and Enel. Their joint bid also required pre-approval by Spain’s National Energy Commission (NEC).

Spain’s policy was widely interpreted as protectionism, as a way of preventing key energy assets from falling into the hands of foreign companies. The European Commission launched legal proceedings against the NEC on the basis that it was infringing the free movement of capital and freedom of establishment.

“By making the acquisition of shareholdings in undertakings in the energy sector and of certain of their assets subject to the prior approval of the national energy commission, Spain has infringed community law,” said the European Court of Justice.

“The system constitutes a restriction on the free movement of capital in as much as it is capable of deterring investors established in other member states other than Spain from acquiring shareholdings in Spanish undertakings operating in the energy sector,” the court said.

The European Commission, which had approved E.On’s EUR42 billion bid for Endesa and which asked Madrid to remove its conditions on the deal, says that it welcomes the ruling.

Madrid has asked the Court for clarification on European Commission rules that limit the power of national energy regulators.

E.On recently gained control of key power generation assets in Spain under a deal with Enel and Acciona.