Portugal 0-1 Spain: Late Morata goal steals place in finals
Alvaro Morata's late goal gave Spain a 1-0 victory over Portugal and snatched a place at the Nations League Finals from their hosts in Braga.
Spain needed to win to leapfrog Fernando Santos' side atop Group A2 but had looked set to be frustrated, with Portugal enjoying the better of the first-half opportunities.
However, substitutions from Luis Enrique after the break changed the game, and Nico Williams' header across goal was smashed in by Morata to steal a precious victory.
The dramatic win means Spain will join Croatia, Italy and the Netherlands at next year's tournament, with Portugal left to rue missed chances and sloppy defending in the closing stages.
Although Spain dominated the early possession, Portugal nearly opened the scoring with a fierce Ruben Neves drive that Unai Simon punched away.
They went close again after 33 minutes when Diogo Jota exquisitely jinked onto his right foot in the box before shooting at goal, but Simon was alert again to tip wide.
While Bruno Fernandes' long-range effort into the side-netting then had Simon scrambling before half-time, the goalkeeper made another crucial intervention early in the second half to deny Cristiano Ronaldo from a tight angle.
Spain still had not registered a shot on target an hour in, so Luis Enrique sent on Barcelona pair Pedri and Gavi in the hopes of turning the game in his side's favour, although it was fellow substitute Williams who made the telling contribution.
Morata had already gone close on a couple of occasions as Portugal keeper Diogo Costa was finally tested, and the Atletico Madrid striker netted the winner in dramatic fashion following Williams' header.
What does it mean? Luis Enrique's men fortunate to win
Spain produced a lacklustre attacking display for the majority of the 90 minutes, but Morata's winner means they will not care.
The visitors registered 1.16 expected goals, but their goal accounted for 0.85 of that. They could have had few complaints had Portugal instead made the final four.
Spain struggled to create chances for much of the game, but Morata tended to be involved when they did.
He attempted four and created another of their 10 attempts, accounting for three of five shots on target – including the vital goal.
Ferran Torres did not have his best game before being hooked by Luis Enrique with Spain needing a goal.
He completed a team-low 59.1 per cent of his passes and failed to register a key pass before being replaced by Williams, who went on to assist Morata's winner.
Both teams are set to squeeze in one more friendly before the World Cup, with Portugal facing Nigeria on November 16 before Spain play Jordan the following day.