Spain managed to advance to the quarterfinal round of Euro 2020 after pulling out a 5-3 victory over Croatia in extra time on Monday afternoon — but the Spaniards allowed the first goal of the game and had their backs against the wall due to a blunder by their goalkeeper.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

Spain goalkeeper Unai Simon received a pass from midfielder Pedri, and since he couldn’t pick up the ball with his hands, he tried to settle the ball with his right foot, but it bounced over his leg and it rolled into the back of the net to give Croatia the early 1-0 lead.

Luckily for Spain -- winners of Euro 2008 -- they were able to bounce back and deliver a victory.

EU'S HEAD OFFICE WORRIED ABOUT EURO 2020 MATCHES IN LONDON

Pablo Sarabia tied the game at 1-1 in the 38th minute. Nearly 20 minutes later, Spain took the lead when Cesar Azpilicueta connected for a header, and then in the 77th minute, Ferran Torres finished Spain’s counterattack to put them up 3-1.

Croatia ended up tying the game when Mislav Orsic buried a goal in the 85th minute, and midfielder Mario Pasalic equalized in injury time to cap the late comeback and send the match into overtime.

CLICK HERE TO GET THE FOX NEWS APP

Alvaro Morata and Mikel Oyarzabal scored in extra time for Spain to send them into the next round of the knockout stage. Spain will take on the winner of France and Switzerland on Friday.

The Associated Press contributed to this report.