It’s a little complicated and I seem to have got into a thread of constant explanation. No matter
Basically if you live in Spain for 3 months or more in any 12 there is a legal requirement to register as a resident and on the Padron. That then follows if you are a ‘resident ‘ by virtue of this you become liable for Spanish income tax. Period.
Also if your principal residency is in Spain they same applies. That’s Spanish law.
If your principal activity and residence is in the UK then that where you pay your tax regardless if you spend 3 months in Spain. HMRC will give you a certificate to produce to the Spanish Hacienda and the double taxation treaty prevents you being charged tax twice.
In short you have to prove to both which country your principal activity is in. The Spanish assume after three months it’s Spain.