Brazil will defend their men's Olympic football title in the final thanks to a classy display of penalty-taking in a 4-1 shoot-out defeat of Mexico following a 0-0 draw after extra time.
The 2016 champions were pushed all the way by Jaime Lozano's side in Kashima but ultimately got the job done on penalties, successfully converting all four of their attempts to reach the final where they will face either Spain or Japan.
Guilherme Arana spurned the best chance of the first half in the 13th minute when he was denied by Guillermo Ochoa with just the goalkeeper in his way.
An even better opportunity looked set to fall Brazil's way soon after as Douglas Luiz was sent tumbling in the box, but the initial penalty award was overturned following a VAR review, with the Aston Villa midfield shown to have exaggerated contact with Jose Esquivel.
The second half was far tetchier, however, with opportunities a rare commodity at either end. The best Brazil could muster until the latter stages was a feeble Antony effort that caused Ochoa no concerns.
Ochoa was beaten in the 82nd minute but the post came to his rescue, with Richarlison's header coming off the inside of the upright but refusing to cross the line.
That saw the match go to extra time and rarely did either side look likely to make the breakthrough, with penalties long appearing a formality.
Eduardo Aguirre missed Mexico's first kick in the shoot-out after Dani Alves had converted, giving El Tri an uphill battle right from the start, and Johan Vasquez did no better with their second as he smashed against the post.
Charly Rodriguez at least got Mexico on the board, but Reinier followed the example set by Gabriel Martinelli and Bruno Guimaraes before him to slot home the decisive kick.