La Roja looked much closer to their best after two draws, sealing their biggest ever win at the Euros.
But the Slovaks were all over the place, with two own goals alongside strikes from Aymeric Laporte, Pablo Serabia and Ferran Torres.
Alvaro Morata even missed a penalty for the Spaniards, saved by Martin Dubravka, before a horror show by the Newcastle goalkeeper sparked Slovakia's downfall.
Dubravka somehow managed to punch the ball into his own net after a shot cannoned up off the crossbar.
Laporte, who switched allegiance from France to Spain before the tournament, doubled the lead with a fine header, then the second-half was a rout.
Pablo Serabia and Ferran Torres both got on the end of flowing Spain moves, before Juraj Kucka turned Pao Torres' effort into his own net.
The emphatic result means Spain will go through to the knockout stages in second place and face Croatia next after Sweden's dramatic win over Poland, while Slovakia's goal difference ensures they will not be one of the best third-place teams.
And on commentary for talkSPORT, West Ham legend Alvin Martin insists the Slovaks only had themselves to blame.
He said: "Before the game Luis Enrique said it was not going to be an easy game. They've been helped along the way and it's been a very easy game.
"Slovakia haven't got a clue what they're doing. They're all over the place.
"They've been guilty of some terrible defending. They've caused their own downfall and some of the gifts they've given to Spain have been unbelievable at this level.
"It's not pretty when you see a team completely overrun. They've got no answers and it's gone from bad to worse for them."