Hi,
Please have a look at article 14 of the UK Spain tax treaty, regarding employment.
(
2014 UK-Spain Double Taxation Convention).
It advises that your UK based employment undertaken while in Spain, will be taxable in Spain, if you spend 183 days or more in Spain in any 12 month
period commecing or ending in the fiscal year concerned.
Thank you.