Yes, any foreigner can purchase a house in Spain. The main thing you will need is a NIE number, which is the identification number given to foreigners in the country. However, there are different types of NIEs, depending on your situation or where you're from.