Spain reached the semi-finals of the men's football tournament at the Tokyo Olympics after surviving an almighty scare against the Ivory Coast.
Manchester United defender Eric Bailly was a surprising opening goalscorer but Dani Olmo levelled before half-time at Miyagi Stadium.
Spain were the dominant force on the ball without finding a breakthrough, and it looked as though they were staring at a shock quarter-final exit when Max Gradel's deflected effort gave Ivory Coast the lead in injury time.
Incredibly, substitute Rafa Mir forced extra time two minutes later, scoring just 58 seconds after coming off the bench.
Spain at last went ahead when Oyarzabal swept home from the penalty spot, Bailly having been penalised for handball after a long VAR review.
Mir completed his hat-trick with two goals in the final three minutes to secure a 5-2 win and send Spain into the final four.
JAPAN STILL DREAMING
Spain will now meet Japan after the hosts battled past New Zealand in Kashima.
There was little to split the sides over 120 minutes, Japan out-shooting their opponents 21 to eight but unable to find a breakthrough.
At the other end, captain Maya Yoshida was the inspiration, posting the highest figures for duel success rate (80 per cent), aerial success rate (71.4 per cent) and blocks (three) of any starting player.
Fittingly, it was Yoshida who converted the final penalty after Liberato Cacace and Clayton Lewis had failed to score, giving Japan a 4-2 win in the shoot-out.
MEXICO WIN CLASSIC TO SET UP BRAZIL CLASH
Brazil's quest to defend the gold medal they won on home soil in 2016 will continue in a semi-final against Mexico.
A solitary goal from Matheus Cunha settled the quarter-final contest with Egypt in Saitama.
If that encounter was cagey, the showdown between Mexico and South Korea was anything but, as a nine-goal thriller was played out in Yokohama.
Mexico led 3-1 at half-time through goals from Henry Martin, Luis Romo and Sebastian Cordova, with Lee Dong-gyeong grabbing a lifeline.
A frenetic contest continued after the break as Lee made it 3-2 only for Martin and Cordova to score their second goals and stretch Mexico's advantage.
Substitute Eduardo Aguirre netted the sixth with six minutes of normal time remaining, Hwang Ui-jo scoring an injury-time consolation.