Tax residency vs "normal residency"

Hi,
I'm considering a move to Spain with the family (we're non-EU citizens).
My company has headquarters in Barcelona and I've been working at one of its branches in my home country for 10+ years. Now the company is willing to arrange for relocation and work permit. The job is completely remote, so as long as I have Internet access, I can work anywhere. Yet I am arranging for this transfer due to differences in social security, education prospects for kids etc. 

My goal is to stay with the company as long as possible, well maybe through retirement. However, not quite sure if me and my family are ready to relocate right now, due to COVID-19 uncertainty and other factors.
My plan is as follows:
1. Get a work permit and start working for Spanish branch; this is a "highly skilled" pathway if that's of relevance.
2. Rent a (cheap) apartment in Spain on a long term basis, but live in my home country for at least 1 more year, with periodic visits to Spain as needed. The apartment will stay empty ~90% of the time, though of course I'll pay rent and utilities.
3. Remain tax resident of my home country (there is a treaty on avoiding double taxation), because my center of vital interest stays in home country, where my family would stay for the moment.
4. Start "accumulating" Spanish residency by sticking to the long-term rental agreement and indefinite work contract.

QUESTION
I understand that in Spain, tax residency and "normal residency" are not necessarily related; however is the option above viable in principle? I.e. if after 1 year of such "remote work" we finally relocate to Spain for good, and continue renting - or purchasing our own property - for 4 more years, would we be eligible for residency at the end of this 5 year period? Or first year will not count?

If you get a work permit and start working for Spanish branch, you will be considered a resident and you are obliged to pay taxes already. Because its a work permit, not only residence permit. Additionally, i believe anyone who stays over 6 months in Spain for whatsoever reason is obliged to file taxes for any income they have. Double taxation treaties would be likely applied by your gestor after you file your taxes.

I dont believe there is any situation like 'my vital interest like my family is in somewhere else' in taxation law - if you have a work permit then you will have income and will have to pay Spanish taxes. If you dont have income, then the work permit may be at risk.

I believe for any legal purposes (tax filing, work permit, residency), you will have to be able to show proof of you being in Spain and doing what you claim to have been doing. This includes working for Spanish branch. 'I was working for Spanish branch but i was remote as a foreigner' would not be applicable for majority of those purposes, i believe. If you were a Spanish citizen, sure. But as a foreigner with a residence+work permit, wouldnt.

You may go start living and working in Spain while frequently getting out to visit and stay with your family. That could sort out everything. Any time you spend outside Spain will not be counted towards any residence quota you may need to fill for applying to anything more permanent like citizenship.

eligible for residency


This part is a bit hard to interpret. The moment you get work permit, it happens with a residency permit. You cant get a work permit without a residency permit as far as i know.

I didn't reply at first because I expected someone more knowledgeable to reply but, as you only have the one I thought I'd chip in.  I agree with what Unity100; says if you live in Spain then you pay taxes in Spain.

Normally living here means that you are here for 183 out of the 365 days in a year but if you have a work permit and a Spanish contract then I'm sure that means you will have to pay Spanish taxes from the get go.

The double taxation arrangements mean that anything that your "home country" demands that you pay there are disregarded by the Spanish tax people but basically Spain taxes your worldwide income.

Normally the employer who gives you the job will sort out your residency paperwork for you so the residency question isn't really a question at all.