We are going to Spain (have visited before) and Portugal (new for us) in October/November this year. We will start and end in Madrid (best for rental car and flights) and are trying to decide, based on the weather mostly, if it is better to head north then towards Santiago De Compostela and then down the coast to Lisbon and back to Madrid, or the other way around. I really don't like the heat and am happy with cold but ideally not rain (which I know we wont avoid). Additionally for clothing it would be good not to have too huge a variation in temperature. I can/have googled temperatures but know from experience (last time we were in Southern Spain it was 10C hotter than it should have been) that google isn't always as helpful as people!
If you are trying to chase cooler weather then it seems sensible to head north first then down the coast of Portugal. You haven't said how you plan to get "back to Madrid" from Lisbon. You could head pretty much due east to Evora, Badajoz and Caceres then on to Madrid, or head south to the Algrave then to Seville and back to Madrid form there.
Thanks for that. I think you are right, we will chase the cool weather and are now going to fly out of Lisbon. The original plan was to drive back to Madrid with a Spanish rental car but we have discovered (thanks to the brilliant advice on this forum) that it is much more cost effective to rent a can in Spain and another in Portugal and take the train over the border.
I tried to plan a a circular tour similar to yours in 2020. The train was very problematic. At that time only ONE train went from portugal to spain and that was an overnight train. Not sure where it originated, but we wanted to go from porto to salamanca, spain. We would have left porto very late at night and got to salamanca at 7 am. Don't know if things have changed. We ended up staying in portugal for 5 weeks; no spain. Also, there was no continuous train from, say, sevilla to anywhere in portugal that I could find. Had to stop a little ways from the border and take a bus to portugal, then find a Portuguese train to lisbon. We went in september/october and lisbon was very hot, like continuously sweating. Check out the website rome2rio.com for info on various modes of transportation.