The backbone is CP (Comboios de Portugal). The Alfa Pendular tilting train runs Lisbon–Porto in about 2h50, stopping at Coimbra and Aveiro; it's the fastest, comfiest option and you should book ahead in summer. Intercidades services extend to the Algarve (Faro, via Tunes) and north to Braga and Guimarães.
Around the cities, urban trains are the secret weapon. From Lisbon you can reach Sintra, Cascais, and Setúbal on the same tap-and-go network; from Porto, the Douro line runs the river valley and the Minho line runs to the coast. Don't rent a car for these.
Book long-distance at cp.pt a few weeks out for the best fares; same-day tickets are pricier and sometimes gone. Senior and youth discounts exist; rail passes rarely beat a couple of singles.