I visited both places, but if I must pick one, Portugal is my preference over Spain. Why? It's safer in relation to Spain as seen here:
https://worldpopulationreview.com/country-rankings/most-peaceful-countries; when it comes to costs like accommodation, eating and moving around, Portugal tends to be slightly cheaper than Spain does. Also, the country of Portugal is smaller compared with how big Spain is. If you can spend 9 days, that's perfect for Portugal. A normal plan should take at least seven days, so you have enough time to really experience the local ways of life and traditions. You can also spend around five or six days in Portugal if you plan to visit mainly the big cities and then use the extra days for traveling in Spain. If your trip is 12 or more days, I would recommend choosing Spain. Finally, I cannot speak Spanish or Portuguese. According to the EF English Proficiency Index
https://en.wikipedia.org/wiki/EF_English_Proficiency_Index Portugal ranks eighth worldwide in English skills, whereas Spain is positioned at thirty-fifth.
I traveled around Lisbon by myself, which wasn't too hard because you can get to many places on foot. However, when I went to Porto, I decided it was best to use a guide from the area
https://gowithguide.com/portugal/porto/guides