Spain made sure of top spot in Group 4 of League A in the UEFA Nations League on Friday night courtesy of a 2-1 victory over Denmark in Copenhagen.
La Roja had already booked their spot in the quarter-finals of the competition ahead of their clash with the Danes, but the narrow success has allowed them to secure first spot in the section ahead of their final game against Switzerland on Monday.
Denmark, meanwhile, remain second in the group, two points clear of third-placed Serbia ahead of their meeting on Monday, so Brian Riemer's side are still in a strong position to advance to the final eight.
The breakthrough arrived in the 15th minute of the contest, with Mikel Oyarzabal brilliantly collecting a pass from Ayoze Perez before finding the back of the net from close range.
Denmark centre-back Jannik Vestergaard gave the ball away in a dangerous area, but there was still a lot to be done, and it was excellent work in a tight area, with Spain silencing the home team's supporters.
The Danes had four attempts in the first period, but none were on target, with Spain proving to be the more productive outfit in the final third of the field despite being without some key players.
Spain's second of the match came just before the hour, and it was another excellent goal, with Dani Olmo's clever pass releasing Perez, who picked out the bottom corner with a brilliant finish.
Perez has scored 10 times in 10 matches for Real Betis this season, while his strike on Friday evening brought his first competitive goal for Spain, having opened his account for La Roja against Andorra back in June.
Spain, who are the holders of the Nations League trophy, conceded a bizarre goal late on, with a poor back pass from Fabian Ruiz being converted by Gustav Isaksen, but the visitors held on for the victory in the closing stages.
DENMARK VS. SPAIN HIGHLIGHTS
15th min: Denmark 0-1 Spain (Mikel Oyarzabal)
Spain make the breakthrough in the 15th minute of the contest, and the goal comes from Oyarzabal, who brilliantly finds the back of the net following a pass from Perez - it is wonderful feet from the Real Sociedad attacker.
Vestergaard gave the ball away in a dangerous area, but there was still plenty for Spain to do to take the lead.
58th min: Denmark 0-2 Spain (Ayoze Perez)
Spain double their advantage in the 58th minute of the match and surely secure top spot in the group, with the goal coming from Perez, who collects a pass from Olmo before excellently picking out the bottom corner.
Perez has brought his Real Betis form into this match.
84th min: Denmark 1-2 Spain (Gustav Isaksen)
Denmark have one back in the 84th minute of the contest to set up a grandstand finish here; it is a horror moment from Ruiz, as his poor back pass goes straight to Isaksen, who has the simple task of tapping home.
MAN OF THE MATCH - AYOZE PEREZ
Perez was excellent for Spain on Friday night, with the Real Betis forward setting up Oyarzabal for the breakthrough goal in the first period, before scoring an excellent second himself in the second half.
The 31-year-old has now managed two goals in four appearances for Spain, and he is making a strong case to be a key part of Luis de la Fuente's plans moving forward, as he is playing some of the best football of his career.
DENMARK VS. SPAIN MATCH STATS
Possession: Denmark 47%-53% Spain
Shots: Denmark 10-11 Spain
Shots on target: Denmark 2-4 Spain
Corners: Denmark 7-7 Spain
Fouls: Denmark 8-17 Spain
BEST STAT
WHAT NEXT?
Spain now have a pressure-free contest against Switzerland on Monday night, with De la Fuente's side booking their spot in the quarter-finals of the competition as section winners courtesy of their success in this match.
Denmark, meanwhile, will take on Serbia on Monday knowing that a draw would be enough for them to claim second in the section, but a defeat would see them finish in third spot in Group 4 of League A and face a relegation playoff clash.