Defending champions Brazil beat Mexico 4-1 on penalties in their men's Olympic football semifinal in Saitama on Tuesday following a 0-0 draw after extra-time.
The match was a repeat of the London 2012 Olympic final, which Mexico won 2-1.
Mexico now have the opportunity to win bronze.
"We are saddened not to be in the final but all is not lost," Mexico midfielder Uriel Antuna said. "We now have to battle for the bronze medal. We want to take that medal home.
"We are a family and we fought until the end. Penalties are a lottery and we got the worst of it. We must bounce back and support those teammates that missed the penalties. They have all my support. The team is still united and we are going to fight for that medal."
Brazil, the holders having won gold in their home Olympics in 2016, had the better of the first half, but the second failed to live up to expectations.
Richarlison came close to winning it in normal time when he hit the post with a header from a Dani Alves cross.
The game went to extra time and, while Brazil looked more likely to break the deadlock, the match finished goalless after 120 minutes and it went to spot kicks.
Dani Alves scored Brazil's first penalty before Eduardo Aguirre saw his spot kick saved. Arsenal forward Gabriel Martinelli then put Brazil 2-0 ahead with a cool penalty and Mexico's second effort through Johan Vasquez hit the post.
Bruno Guimaraes stepped up and put Brazil in total control before Carlos Rodriguez got Mexico on the board. With the scores at 3-1, Reiner knew a goal would clinch it for Brazil and made no mistake.