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 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.
Press release nr. IP/13/365, 25 April 2013