Luis Enrique's men required a win in Thursday's (AEST) clash to guarantee a last-16 spot after drawing their first two games and were given a huge helping hand by Dubravka.
The Slovakia keeper saved an Alvaro Morata penalty early on – the fifth in a row Spain has missed – before comically flapping the ball into his own net with half an hour played.
That put Spain on its way to an emphatic win, the first time it has ever scored five times in a European Championship match, after Aymeric Laporte's first international goal and strikes from Pablo Sarabia and Ferran Torres before Juraj Kucka's own goal.
Spain was awarded a penalty inside the first 12 minutes after VAR intervened and adjudged Jakub Hromada fouled Koke when attempting to clear the ball.
Dubravka dived to his right and got two hands to the powerful attempt but, after chances went begging for Sarabia and Pedri, the keeper went from hero to zero.
Sarabia's long-range shot looped into the air after striking the crossbar and Dubravka, under a bit of pressure from Morata, inexplicably pushed the ball into his own net.
Dubravka could have done better for Spain's second goal, too, as Gerard Moreno beat the marauding keeper to a ball and crossed for Laporte to head into the top-right corner.
Spain was in complete control of the game when Sarabia swept home Jordi Alba's pass into the bottom-right corner with 56 minutes on the clock.
Slovakia still had a chance of advancing as one of the best third-placed sides, but substitute Torres flicked Sarabia's cross past Dubravka just 44 seconds after entering the pitch and Kucka knocked the ball into his own net soon after for Spain's fifth.