Mexico survived a stunning Senegal comeback as they won a Wembley thriller 4-2 after extra-time to reach their first Olympic Games semi-final since 1968.
The Mexicans blew a two-goal lead with just over 20 minutes remaining, but Tottenham's Giovani dos Santos and substitute Hector Herrera punished extra-time errors to set up a guaranteed medal match.
Poor defending also saw Mexico go 2-0 ahead through Jorge Enriquez and Javier Aquino before Senegal scored twice in seven minutes to equalise through Moussa Konate's fifth goal of the tournament and a header from substitute Ibrahima Balde.
The Africans, who finished runners-up to Great Britain in Group A, also wasted a succession of chances in what was arguably the match of the tournament so far.
Mexico will now meet Japan, who maintained their pursuit of double Olympic Games Football gold as the men followed the women into the last four courtesy of a routine 3-0 win over Egypt.
Women's World Cup holders Japan stunned Brazil yesterday to set up a semi-final clash with France at Wembley on Monday.
Just 24 hours later, the men clinched their own Wembley date, with Kensuke Nagai, captain Maya Yoshida and Yuki Otsu all on target in their quarter-final clash with 10-man Egypt, who had defender Saadeldin Saad sent off.
Leandro Damiao fired Brazil into the last four as they overcame a major scare against nine-man Honduras to win 3-2.
The Internacional striker cancelled out Mario Martinez's stunning opener, and after Neymar had done the same from the penalty spot following Roger Espinoza's equally eye-catching 48th-minute finish, Damiao booked a trip to Old Trafford on Tuesday with his second goal.
Honduras played a full part in a thrilling encounter at a packed St James' Park despite having midfielder Wilmer Crisanto sent off with just 32 minutes gone and Espinoza at the end, both for two bookings.
In the final game of the night, Great Britain went out in painful fashion as they finished 1-1 with Republic of Korea but then lost a penalty shootout 5-4.
Chelsea striker Daniel Sturridge missed the vital last kick, allowing Celtic's Ki Sungyueng to send the Koreans into a last four meeting with Brazil.