According to a recent press release of the European Commission, it has decided to refer Spain to the EU’s Court of Justice for discriminatory real estate tax rules that prevent non-residents from enjoying the same tax benefits as residents.
According to the Spanish legislation, capital gains from the sale of a permanent residence are exempt for tax if the money is used to buy another permanent residence. However, this provision only applies to Spanish residents, therefore discriminating against non-residents who can end up paying much higher taxes. In other words, the exemption applies as long as you keep on being a tax resident in Spain
In practice if a person living in Spain sold its permanent residence to buy a new house in another Member State where he would move, he could be taxed on the capital gains made on the sale. Conversely if he had stayed in Spain and bought a new house there, he would not have been taxed.
The Commission considers that this is an obstacle to free movement of persons, workers and self-employed persons and therefore breaches the EU Treaties.