Yes, but you need a permanent address, and you need to be on the Padron (this is similar to the electoral role in the UK). You can apply if you have an 11-month rental contract and are on the Padron at this address. Once you complete on your property the address can be altered to the new one. You must be living in Spain, not visiting.