BRAGA, Portugal- - Spain snatched a place in the Nations League final four after striker Alvaro Morata's late goal secured a 1-0 win over hosts Portugal on Tuesday to ensure top spot in their group.
Portugal dominated the match but Spain stayed in the contest and in the 88th minute Morata lashed the ball home to silence most of the sold-out stadium after a long ball into the box from Dani Carvajal was headed back across goal by Nico Williams.
Spain finished top of League A-Group 2 on 11 points from six games, one point above second-placed Portugal who only needed a draw to secure a spot in the semi-finals.
The Spaniards join Croatia, Italy and the Netherlands in next year's finals tournament.
"It was a difficult game but I stay with the attitude of the team. We have made a great effort," Morata told reporters.
"If we were knocked out it had to be by leaving everything on the field and that's how it was one more time for us.
"Every time that Spain have to show up in big games we do it. That's how we do it and tonight we did it again."
It was a bitter blow for Cristiano Ronaldo's Portugal who created several chances, were in total control during most the game and looked so close to securing a place in the finals.
The hosts almost opened the scoring in the 32nd minute through Diogo Jota, who received a long pass from Bruno Fernandes and lashed a shot towards the top right corner that Unai Simon kept out with a brilliant one-handed save.
Fernandes almost scored himself five minutes later when he rifled a cross shot into the side netting with an effort that was so close the home fans thought it was a goal.
Spain looked lost and confused in what was looking to be another lacklustre performance after they went down 2-1 at home to Switzerland on Saturday.
Spain manager Luis Enrique sprung a surprise with seven changes to his starting lineup, leaving Barcelona's Sergio Busquets, Gavi, Pedri and Jordi Alba on the bench.
It was not until he made four substitutions in the second-half that Spain woke up and got their first shot on target of the game after 70 minutes through Morata.
The Atletico Madrid forward almost scored in the 76th minute when he fired a long-range shot towards the bottom right corner that Diogo Costa kept out with an outstanding one-handed stop.
Ronaldo tried hard to score but his play was often erratic and he was unable to successfully link up with his team mates, who kept missing chances and left Spain in the game, allowing Morata to be the hero again with his late winner.