If you are a Portuguese resident, you are taxed on your worldwide income. However, if that income is taxed in the other country, then you can get relief under the double tax agreement, with the refund provided by Portugal.
As an example, let’s say you’re from the US, you live in Portugal and you are a legal resident of Portugal. Portugal will tax you on all of the money that you make worldwide, which includes income in the US, in Portugal, and in any other country; it makes no difference. But if you have paid tax on the same income in a foreign country, you can claim a deduction on your Portuguese tax return of the tax that was paid or withheld in the foreign country. You get a tax credit, which will then lower the amount of tax that you pay in Portugal.
In order to be a tax resident of Portugal, you have to be in the country for 183 days within the year or alternatively, you could rent a home, which is considered to be your permanent residence. If you are not a tax resident in Portugal, you are only taxed on the income that you earn in Portugal and not on your other worldwide income.
There is a special regime that was set up about 5 years ago, which institutes a special 10-year tax holiday for people who come to retire to Portugal from another country, called the Non-Habitual Resident Regime. If people who qualify receive foreign income in Portugal, they have to declare that income but they do not have to pay tax on that income for 10 years. This includes both earned income and retirement income. They will only pay taxes on the income that they earn in Portugal. This tax regime has attracted a lot of Northern Europeans to come to Portugal. It has also attracted a lot of French people who were trying to escape the very high taxes that are now being applied to wealthy people in France.
There has been a big takeover bid by the left wing parties who are now the governing parties in Portugal. They may overturn this particular regime in order to fund the increase in pensions of the local people and increase the salaries of the public servants, which were cut under the previous government. Whether they will overturn it or not, I cannot answer, but I can report that Portugal has a habit of introducing really attractive legislation (for example, doing away with inheritance tax) and then when another government comes in, the legislation may get repealed. When this happens after a lot of people have already made arrangements, it can become an absolute nightmare.
(The town of Évora, Portugal shown with its medieval walls, drawn in 1501, pictured.)