CNN  — 

Spain has found it tough to score goals at Euro 2020.

In its opening two Group E games, Spain had scored just once, missing a whole host of chances including a penalty and leaving its qualification to the round of 16 stage in jeopardy.

And needing a victory against Slovakia to guarantee its progression, Spain found an unlikely goal scorer: opposition goalkeeper Martin Dubravka.

READ: UEFA facing criticism over its position on rainbow colors ahead of Germany vs. Hungary match

Slovakia's goalkeeper Dubravka scores an own-goal while attempting to clear the ball.

The Newcastle United keeper initially started the game strongly, saving Alvaro Morata’s penalty early on to keep Slovakia in the game.

However, after a poor clearance from defender Lubomir Satka fell to Spain attacker Pablo Sarabia, the Paris Saint-Germain forward’s strike hit the bar and the ball went up in the air.

Looking to palm it over the bar and to safety, Dubravka misjudged horribly and palmed the ball into his own net to his dismay.

Things went from bad to worse for Dubravka when his indecisiveness later in the half allowed the ball to be crossed for Aymeric Laporte to head home his first Spain goal and give his side a 2-0 lead.

Visit CNN.com/sport for more news, features, and videos

Dubravka scores an own goal and the first for Spain.

Morata’s miss from the penalty spot continues Euro 2020’s trend of missed spotkicks. It was the 11th penalty awarded this tournament, with six having been missed.

And two goals ahead suddenly the shackles were off for Spain, with Sarabia, Ferran Torres and a Juraj Kucka own-goal rounding off an impressive 5-0 victory.

Spain finished second in Group E after Sweden secured a see-saw 3-2 win against Poland in St. Petersburg, Russia to top the section.