Brazil and Spain overcame tricky tests to reach the semi-finals of the men’s Olympics football competition.
Defending champions Brazil saw off Egypt 1-0 thanks to a goal from Matheus Cunha while Spain were seconds away from going out to Ivory Coast.
Former Leeds and Leicester midfielder Max Gradel put the African side 2-1 up in stoppage time but Wolves striker Rafa Mir scored in the 94th minute.
Mir then completed a hat-trick in extra-time as Spain secured a 5-2 win and set up a semi-final against hosts Japan.
They beat New Zealand on penalties after a tense goalless draw. Brazil will face Mexico - winners in London - who saw off South Korea in a thrilling 6-3 win.
“We would’ve liked to have scored in the 90 minutes but New Zealand are a good team and really gave us a tough game,” Japan coach Hajime Moriyasu told reporters.
“It’s going to be a tough game in the semi-finals, but we will stick together as a unit and battle it out to the death and try and reach the final.”