There is a way that you can live in Spain without registering there as a freelancer but what determines whether you can do this is the amount of money that you make, not time. If you make less than a certain amount of money (usually a couple of thousand Euros but it changes every year), you do not have to register as a freelance. I believe that the figure is based on taxes: if you do not make enough money to need to pay taxes (i.e. you do not go over the threshold), you can invoice without being registered.
Be warned: The Spanish authorities are looking to crack down on those who move to Spain and work as freelancers without registering! If you go over the threshold value and don’t register, they may deal with you harshly.
If you find that you do need to register, here is a useful guide: How to become an autónomo (freelancer) in Spain