If you stay in Spain for more than 183 days a year, you are considered a resident.