Portugal had a late chance to earn the point it needed but Cristiano Ronaldo missed from close range to see his scoreless streak with the national team reach three matches.
Spain needed a victory to return to the Final Four after losing last year’s final to France. Portugal won the competition’s inaugural edition at home in 2019 but hasn’t made it past the group stage since then.
Spain struggled to create chances until Dani Carvajal found Nico Williams inside the area and the young Athletic Bilbao forward headed the ball back across the box for an easy strike by Morata into the open net.
Spain had been in control of the group until losing 2-1 to Switzerland at home last weekend, while Portugal took over first place with a 4-0 win over the Czech Republic.
Spain hadn’t been able to win in Portugal in nearly two decades, since a friendly in 2003. It got its first competitive away victory against Portugal since a 2-1 World Cup qualifying triumph in 1934.
The Iberian neighbours had drawn their last four matches including friendlies. Spain’s last triumph against Portugal had come in a penalty shootout in the semi-finals of the 2012 European Championship.
Spain also needed a last-day victory to make it to the Final Four last year, shocking Germany 6-0 at home.
Additional reporting from AP