You can buy a property anywhere in the country.
However, there are some bureaucratic steps that you need to overcome.
For example, you will need to obtain a Portuguese taxpayer number (NIF) before completing the purchase of a property. You will need to register with your local tax office.
In case you are not yet residing in Portugal, you can provide your portuguese lawyer's address, as your mailing address.
If you are a non-EU citizen, you will also need to appoint a tax representative in the country.
Portuguese banks can grant loans to foreigners, although they only lend 70% of the property's value to non-residents - which can reach up to 80% if you become a resident.
You will simply have to apply for a credit at a local bank.