Right Dermot; firstly clarify the Spanish taxation position. Just Answer is essentially an UK based tax advice site. Your gain is 50K + 50K - 450K = 350K. Spanish capital gains are taxed as investment income at the following rates:
Up to €6,000 21%
€6,000 to €24,000 25%
Over €24,000 27%
AngloInfo Spain advise:
'Main home relief/exemption if under 65
Reinvestment relief is available to Spanish residents when they sell their main home and invest in a new one.
To qualify for this relief, the property must be your main residence and you must have lived in it continuously for at least three years (less if you had to sell because of a change of job, marriage etc.) from the date of sale or completion. You must then buy a new main residence within four years, starting two years before the sale.
Main home exemption if over 65
If, as above, you have lived in the property as your main home for three years or more, if you are over 65 years of old when you sell it, the gains are exempt from capital gains tax even if you do not buy a new property.
Again, you must be able to show you have been tax resident in Spain.
There is an excellent summary of the position here: