The Japanese men looked set to join their women's team in setting up a gold medal match at London 2012 when a superb third goal of the tournament from Yuki Otsu gave them an early lead in Tuesday afternoon's semi-final.
But Marco Fabian, Oribe Peralta and substitute Javier Cortes turned the game around as Mexico set up a final on Saturday against Brazil or South Korea and left their opponents playing for bronze.
Neither side had previously competed for gold and each had made the Olympic semis for only the second time, having last done so in 1968 when Japan went on to beat host nation Mexico in the bronze-medal match.
And despite some nervy defending early on, the Japanese were on course to emulate that result after 12 minutes on Tuesday thanks to a stunning strike from Otsu.
Mexico goalkeeper Jose Corona, who had already tipped a Hiroshi Kiyotake 25-yarder wide, was helpless as Otsu's instant control from Keigo Higashi's pass set up a 20-yard half-volley the forward crashed into the top corner.
It was the first time the Central Americans had trailed at the Olympics and they now needed to become the first side to score against Japan.
Fabian scuffed his finish after some slack defending and Giovani dos Santos drilled wide when the ball fell to him from a blocked shot.
The pressure told in the 31st minute when Dos Santos' corner was flicked on by Jorge Enriquez and Fabian nodded home from close range.
Neither side could force a second before half-time, after which the game got increasingly tetchy, Hiroki Sakai eventually booked for a foul on Fabian.
Mexico continued to call the shots and completed their comeback in the 65th minute with a goal that was both sublime and ridiculous.
Peralta had just drilled too close to Shuichi Gonda, who rolled the ball out to Takahiro Ohgihara.
But the midfielder dallied and was robbed by Peralta, the striker still having plenty to do as he drove an unstoppable strike right into the top corner.
Ohgihara almost made amends with a free-kick that was met by a looping backheader from Kensuke Nagai and was tipped over by a backpedalling Corona.
Japan threw on Kenyu Sugimoto, Takashi Usami and Manabu Saito but they were unable to find a way through and were overcommitted in the final minute of stoppage-time as Cortes held off several weak challenges before firing the ball under Gonda.
The push for more color on their cleats, adidas has added the infrared colorway to the adiZero f50 Line.
One of the top soccer cleats for control the Nike CTR360 will not let you down on the field in tight spaces.
The Liverpool 2013/14 soccer jersey is available for pre-order. The Reds are eager to compete for silver next season.
Ajax has released their away soccer jersey for the 2013/14 season. Get in the Gear.
adidas has added some color to the Predator line with this new colorway. Released on May 17. Be the first to own a pair.
Chelsea won the Europa League on Wednesday. The Blues defeated Benfica 2-1 on injury time goal from Ivanovic.
Bayern Munich are kings of Germany and hope to be crowned kings of Europe at Wembley later this month!
The Juventus jersey for the 2013/14 was released earlier this week. Be the first to wear the colors of the Old Lady.
The new PUMA evoSPEED 1.2 FG. A great new soccer cleat with classic look and first time for PUMA to be on the cleat.
Borussia Dortmund hears Wembley Calling and are headed to London for the Champions League final.