La Roja trailed after just 10 minutes into their last-eight clash after Eric Bailly bundled the ball into the back of the net from a corner.
Dani Olmo brought them level at the half-an-hour mark. The scores remained the same at the interval after some top-class saves from Unai Simon.
In the second half, Mikel Oyarzabal scored with a lovely volley, but the goal was ruled out for offside in the build-up play.
In stoppage time, Max Gradel appeared to have bagged the winner for Ivory Coast, but La Roja made a sensational comeback.
Rafa Mir scored within minutes of coming off the bench after a defensive misunderstanding between Kouadio-Yves Dabila and Bailly.
In extra-time, La Roja took the lead through Oyarzabal in the 98th minute. He scored a penalty after a bizarre hand ball from Bailly.
Mir put the game beyond Ivory Coast with two quickfire goals before the end of extra time. His hat-trick came up with just 10 touches.
This has got some Wolves fans talking. Here are a few reactions on Twitter.
Said it before but Rafa Mir has got to be given a proper chance with us. Has improved massively since his loan playing regularly at Huesca #wwfc
— Rob James Cook 🐺 (@RobJCook1) July 31, 2021
We should give Rafa Mir some starting time at wolves. He is a goal machine honestly. We need to start him in some of the cups.
— . (@jacksfifathings) July 31, 2021
For how much could Wolves sell Rafa Mir?
— Luca🇵🇹🐺 (@LucaDFC) July 31, 2021
Wonder if this Rafa Mir will time up for Wolves this season? Or do we sell before he leaves on a free? https://t.co/7017U3eOca
— Geoff Whitehouse (@ByGeoffW) July 31, 2021
That loan spell seems to have to done Rafa Mir the world of good. Deserves another crack with us #WWFC
— Pete Jackson (@pete_wwfc) July 31, 2021
Mir has been with Wolves since the 2017/18 season, but he has been restricted to just four senior appearances across all competitions.
He has spent time on loan with three different clubs. He was impressive for Huesca in La Liga last term, bagging 13 goals from 38 league outings.
The Spaniard has entered the final year of his contract, and it appears likely that he will move on unless manager Bruno Lage has different plans.
The Midlands outfit will hope to get a decent fee out of him. The striker has enhanced his reputation further with the recent display at the Olympics.
Spain have reached the last four of Olympic football for the first time since 2000. They will meet Japan, who beat New Zealand via a penalty shoot-out.
Stats from Transfermarkt.com