URGENT UPDATE: Portugal just passed a law that, upon request of International protection they will be given automatically social security number, fiscal number and health system number! This will be provided by teams at airports and in nearby locations named "ACM". A list of locations will be published here as soon as available!!
As mentioned, if your are entering Portugal from a country from the Schengen area, you do not require any documents as long as you remain in the Schengen area for less than 90 days.
To extend your stay beyond this time, you can:
You can apply for Asylum either directly at the Immigrations and Border Service on arrival or later on, either at one of the many Immigration Services (called SEF, or “Serviço de Estrangeiros e Fronteiras”, Service of Foreigns and Borders) available in almost every Portuguese city or, in alternative, with a local police force (we have two, GNR, “Guarda Nacional Republicana” and PSP, “Polícia de Segurança Pública”). This Asylum application can be made both in person or in writing.
You can find the Asylum Seekers Manual here:
https://www.sef.pt/en/Documents/Guia_EN_.pdf
You will be allowed to remain in Portugal while the request is pending and, of course, if later approved!!
Please register at this portal:
https://sapa.sef.pt/an/default
After the registration, you can fill in a form and apply for an appointment in SEF (this is a service for foreigners).