I bought a EuroRail Pass because we are going to travel around Europe for 3 months this summer. I'm trying to book an overnight train from Lisbon to Madrid, but the EuroRail site says I have to book this at the train station. Has anyone done this? Are all trains in Portugal booked only at train stations?
Unfortunately the night trains between Lisbon and Madrid were cancelled when the pandemic struck and it is currently unknown when or if they will return.
There are day trains, but they require a couple of changes and take a while. So a stop along the way is recommended.
And make sure you keep your travels to 90 days and not three months. There is a difference so count carefully. The Schengen zone takes the 90 day limitation very seriously.
There are no through trains on that route. It appears this is the rail route:
Portuguese train departing Lisboa-Santa Apollonia 8:45 AM to Badajoz (Spain), arriving 2:14 PM (you lose an hour when you cross the border)
Spanish train departing Badajoz 2:30 PM, arriving Merida 3:14 PM
Spanish train depating Merida 3:20 PM, arriving Madrid-Atocha Cercanias 8:10 PM
You could also stay on the second train all the way to Puertollano and change there, but you'd arrive at 8:28 PM and it might cost more.
There are flights, of course. Even for me, that's a lot of time on a train. If I didn't want to fly, I'd try to develop a burning desire to see one of the cities along the way. Merida has some Roman ruins and a nice archaeological museum but is otherwise not really an interesting place. That area (Extremadura) is unpleasantly hot in mid-summer, but Caceres is definitely worth visiting. It would require a detour to the north, but it's accessible by train from Merida. Service is infrequent, but there's a departure at 3:20 PM and the trip takes less than an hour.
In addition to the route acraven mentions, there is another option.
Train from Lisbon to Porto (2:50), then another train from Porto across the border to Vigo (2:30). From Vigo you can then take a high speed train to Madrid (4:15). A bit shorter travel time in total, but I'm not sure how well the schedules match. However, borth Porto and Vigo are worth a stop along the way.
Forget about trains between Portugal and Spain. No good connections. Better walk! Or fly (there are still good connections flying, untill we find out them.).
Connecting with Spain is not good.