
The European Court of Justice has ruled Spain broke competition rules by trying to obstruct a German takeover of Spanish energy firm Endesa and by insisting mergers in its energy sector be pre-approved.
In February 2006 E.On made a 42.5bn-euro ($60bn; £30bn) bid which was approved by the European Commission.
However the Spanish energy regulator placed 19 conditions on E.On's 2006 offer, which E-On withdrew in April 2007.
In another case Spain attempted to prevent a bid for Endesa by Italian energy company Enel and Spanish construction group Acciona, by making certain of their assets subject to the prior approval of the national energy commission
The actions were considered to be part of a wider attempt by Spain to prevent foreign utilities from taking stakes in domestic energy sector.
"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," the European Court of Justice said.
The European Commission took Spain to the court, accusing it of restricting the free movement of capital.
"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 action against Spain was brought by EU Internal Market Commissioner Charlie McCreevy.
"Commissioner McCreevy welcomes the ruling of the court, which confirms the consistent line that special rights have no place in the internal market," his spokesman said.