Oribe Peralta scored a dramatic winner as Mexico came from behind to defeat New Zealand 2-1 in Sochi and move top of Confederations Cup Group A.
After Juan Carlos Osorio made eight changes to Mexico's team, it looked like he would pay the price when Chris Wood gave New Zealand a shock first-half lead, the first time his country have scored in six Confederations Cup matches.
But Raul Jimenez's third goal in his last four internationals brought Osorio's men back on level terms after the break and Peralta's winner ensured El Tri secured victory despite star striker Javier Hernandez remaining on the substitutes' bench.
Mexico, winners of the tournament in 1999, now know a point in their final match against Russia – who lost to Portugal earlier on Wednesday – will ensure they reach the semi-finals.
New Zealand, meanwhile, crash out after a heart-breaking defeat, Ryan Thomas hitting the crossbar late on. They are yet to taste victory in 11 Confederations Cup matches.
They cannot catch Mexico or Portugal – both of whom are on four points – going into their last match against the European champions on Saturday.
In an even start to the match, Giovani dos Santos was denied by a superb Thomas block after a swift Mexico counter-attack, while New Zealand's Tommy Smith had a header saved by Alfredo Talavera at the other end.
There was then huge controversy as New Zealand squandered a brilliant opportunity. Wood fended off a challenge from Carlos Salcedo and was left unmarked 18 yards out, but was unable to beat Talavera, who got down to make an impressive save.
Salcedo was injured in the incident and left the field on a stretcher as Osorio fumed on the touchline, with Hector Moreno – scorer of Mexico's late equaliser against Portugal last time out – brought on.
New Zealand were not to be denied, though, taking the lead three minutes before the break. A poor defensive clearance from Nestor Araujo led to Clayton Lewis slipping a slick pass through for Wood to finish with a first-time, right-footed strike past Talavera from 12 yards.
Mexico brought on Hector Herrera after the interval and piled on the pressure early in the second half, Giovani firing over from a glorious chance after a move that had seen Javier Aquino impressively denied by Stefan Marinovic's sharp save.
El Tri did equalise in the 54th minute, Aquino charging down the left and linking up with Marco Fabian, who in turn found Jimenez, with the striker's shot on the turn taking a slight deflection and proving too hot for Marinovic to handle.
Diego Reyes had a header saved as Mexico's pressure continued before their third substitution saw Moreno replaced by Rafael Marquez.
Mexico completed the comeback with 18 minutes remaining, the impressive Aquino getting all the way to the byline and cutting back for Peralta to beat Marinovic at his near post from seven yards
Smith had a close-range header saved for New Zealand before Jurgen Damm fired just over after his superb solo run at the other end threatened to seal victory.
Thomas curled a magnificent late strike against the bar from the edge of the area in the closing stages with New Zealand's last major chance.
Mexico were denied a third when Smith made an impressive goal-line clearance after Jimenez had fired a shot past Marinovic.
Tempers frayed on both sides before the conclusion of a contest filled with incident, a rift caused by Michael Boxall's challenge on Herrera leading to three yellow cards after a VAR review as Mexico ultimately prevailed to move a step closer to the last four.