Portugal's rail system feels a bit worn in places, and some trains look terrible from outside...but the interiors are clean and the system seems to work. Not a terribly large country, so that time between the two largest cities (Lisbon and Porto) is about 3.5 hours. If you add in getting to the airport early and getting in from the airport at the other end, it's probably faster than flying.
Other significant points in Portugal also have reasonable rail service, including Coimbra, the university town in the middle, and the vacation beaches of the Algarve in the south. It pays to check prices and routes, by the way. It's one of the few countries we've traveled lately where advance purchase doesn't help much, but good advice (from the ticket agent!) can really help. For instance, from Coimbra to Porto, we saved half because he showed us a regional train from Coimbra that met a Porto regional train about halfway between. A ticket on the "high-speed" train would have required two changes and been only 9 minutes faster!
I'm not as familiar with Spanish trains except in limited areas...suggest you try a wonderful resource: Mark Smith's site, http://seat61.com