I am not sure what you consider expensive, but I find most Mediterranean countries to be much more reasonably priced than other places in Europe, and of course, many places here in the USA. For me, Portugal and Spain have always been extremely affordable.
I was in both Madrid and Rome in August--the four star hotels I stayed in averaged about $250.00 US dollars per room per night; five star hotels in Spain were still under $400.00, while in Rome five star prices could skyrocket from $500.00 to $1000.00. You can definitely always find cheaper hotels if you reduce the star category, and the hotels are still comfortable and well located. Barcelona is similar.
We are traveling to Zermatt (Switzerland) next month, and the hotel prices are absolutely outrageous, but it is a bucket list trip for husband. I found a three star for about $425.00 per night!!! I booked the hotel ten months in advance--the entire town is almost sold out now! It never hurts to confirm a place months ahead if you are happy with the price and the hotel reviews. I book some cruises two years in advance!
I just took a look at Hotels.com for the end of May/early June and I found at least a dozen Barcelona hotels with excellent reviews all costing less than $250.00 per night. A few even have roof top pools! I wish I could find a New York City hotel for that kind of price.
My advice is book a lower cost city hotel because you are out and about exploring most of the time, and then splurge if you stay at a bigger resort hotel somewhere near a beach. You can also try to stay a little outside of the big cities, and then prices will go down a bit as well, but it may involve more of a commute.
Extensive research is always key to getting good prices, and organizing everything to meet your budget parameters. Best wishes!