How Portuguese surnames began
Portuguese surnames developed alongside Spanish ones in the Middle Ages, and many patronymic names share the same roots, often ending in "-es" (Fernandes, Rodrigues, Gonçalves). Religious names (Santos, Conceição) and names from trees and places (Oliveira, Pereira, Silva, Costa) are also very common.
Portugal's maritime empire carried these names to Brazil, Angola, Mozambique, Cape Verde, Goa and Macau, and Brazil today has far more people with Portuguese surnames than Portugal itself.
How the names work
Portuguese and Brazilian names usually include more than one surname, but the order is the reverse of Spanish custom: the mother's surname comes first and the father's last, and the last surname is the one used on its own. People often carry three or four surnames, and choose freely from their family names. Women may add their husband's surname at marriage.