Doubles from Santi Cazorla and Paco Alcacer secured Spain’s place at Euro 2016 in a 4-0 win over Luxembourg in Logrono.
The victory came at a cost for Vicente del Bosque’s side, with David Silva and Alvaro Morata both coming off with first-half injuries.
Cazorla had hit the crossbar but made no mistake shortly before half-time when he smashed home after Pedro’s shot had been parried.
Substitute Alcacer converted with an impressive finish midway through the second half and then struck again late on with a tap-in, before Cazorla wrapped up the victory with a second of his own – an impressive strike from the edge of the box.
The win means Spain finish top of Group C with one match to spare, having won eight of their nine qualifiers, and will have the opportunity to defend their European crown in France next summer.
Morata twisted into the penalty area early on and shot straight at Jonathan Joubert, before Spain suffered their first injury blow.
Silva was fouled by Lars Gerson after just six minutes and – despite attempting to continue – had to come off for Juan Mata with what appeared to be an ankle injury.
Spain almost shrugged off the loss of the Manchester City star with an immediate goal, but Jordi Alba somehow struck over from close range following Cazorla’s shot.
Ricardo Delgado headed wide for the visitors from a corner, but it was the hosts doing almost all the attacking.
Cazorla looked to have broken the deadlock with a left-footed strike from the edge of the area, but the crossbar came to Luxembourg’s rescue after the Arsenal man had been set up by Morata.
Moments later, Cesc Fabregas slipped in Morata, who dragged an effort past the far post, while Pedro forced Joubert to save with a stinging effort from distance.
Spain suffered another first-half setback when Morata had to be stretchered off the field having landed awkwardly on his leg, with Alcacer replacing him.
Pedro and Alcacer were both off target with two more decent chances, while Stefano Bensi fired wide with a decent effort at the other end.
But what looked like being a frustrating first half for the European champions ended positively with the opener on 42 minutes.
An impressive cut-back from Juanfran on the right found Pedro, whose shot was parried by Joubert, allowing the onrushing Cazorla to smash home with his right foot from the close-range rebound.
Aurelien Joachim almost had Iker Casillas worried with a cheeky long-range effort which was not too far away early in the second half, but Spain went two up when a magical throughball from Fabregas on 67 minutes cut open the away defence and substitute Alcacer converted with a cool one-on-one finish.
After squandering one chance to double his tally, the Valencia striker made up for it with 10 minutes remaining. Weak goalkeeping from Joubert allowed Alba to acrobatically scoop the ball across the face of goal right on the bye-line, giving Alcacer a simple tap-in.
Cazorla got his second of the match on 85 minutes when he picked up a pass from Nolito and found the bottom corner with an impressive low strike from the edge of the area.