Defending champions Brazil will face Spain for the Olympic gold medal in men's soccer.
Brazil beat Mexico 4-1 on penalties after the game ended goalless after extra-time while Spain beat host Japan 1-0 with Marco Asensio scoring a curling shot in the 115th minute in Saitama.
Brazil went close to settling the match inside 90 minutes when Richarlison struck the post with a glancing header in the 82nd minute.
But when it came to the shootout, they had their keeper Santos to thank for a fine save to keep out Eduardo Aguirre's spot-kick after Mexico's Johan Vasquez hit the post, leaving Brazil just needing to keep their cool.
Reiner's right-footed shot into the bottom corner ensured victory for the team captained by 38-year-old former Barcelona full-back Dani Alves.
Brazil won their first Olympic title five years ago at the home Rio Games by beating Germany on penalties.
Mexico will play Japan for the bronze medal in Saitama on Friday and the gold medal match is set for Saturday in Yokohama.
Brazil won their first Olympic title at the 2016 Rio de Janeiro Games in a penalty shootout with Germany.
Neymar converted the clinching penalty at the iconic Maracana Stadium.
Spain's only Olympic title also came at home - at the 1992 Barcelona Games.
The country's last final was at the 2000 Sydney Games, losing to Cameroon.
- with AP
Australian Associated Press