Martin Zubimendi opened the scoring after capitalising on Portugal’s poor defending, before Nuno Mendes quickly equalised for Portugal.
Mikel Oyarzabal scored to give Spain a first-half lead before Cristiano Ronaldo scored a second-half equaliser; he now has a record-breaking 138 goals for Portugal.
After a goalless extra time, Diogo Costa saved Alvaro Morata's penalty, and Ruben Neves scored the decisive penalty for Portugal.
Portugal secured their second Nations League title, having previously won in 2019.