It depends if you want it for your permanent residence, or as a holiday home.
Whichever, you need to employ a reccomended Spanish solicitor who understands the complex land registry rules out there and can guide you through all the correct processes.
Foreign property ownership can be tricky if you are not already, or planning to become a citizen, so you can get caught out in all kinds of legal traps.
Make sure you explore everything very thoroughly before you even think of embarking on this process, and be sure that your reasons for buying are sound, and are going to give you what you want.
It's a riskly business at the best of times - be careful.