After Leeds United striker Chris Wood gave the All Whites a shock first-half lead, second-half goals by Benfica’s Raul Jiminez and Peralta sealed Mexico’s win.
The result in Sochi saw Mexico leapfrog Portugal, who earlier beat Russia 1-0 in Moscow, into top spot in Group A by the slenderest of margins on goals scored.
Juan Carlos Osorio’s side now just need a draw against Russia in Kazan on Saturday to be sure of reaching the semi-finals, but New Zealand are bottom of the group and out of the tournament.
New Zealand coach Anthony Hudson had vowed they would bounce back after Saturday’s opening 2-0 defeat by Russia and his team were true to his word.
Their superb first-half display rattled Mexico and a tense match boiled over with a mass brawl in the dying stages.
“Everyone is incredibly disappointed in the changing room and we feel we should have got more,” said Hudson.
“It was an incredible first-half performance from us.
“The first 10 minutes after the break, we gave them too much space and time on the ball.”
Wood’s superb strike was New Zealand’s first goal in four matches and only the third time they have scored at a Confederations Cup in four campaigns.
With star striker Javier Hernandez on the bench, Mexico’s three-man attack of Peralta, Jimenez and Juergen Damm struggled to make an impact early on.
There was also no place for promising winger Hirving Lozano, 21, who signed a six-year contract for PSV Eindhoven on Monday.
Mexico lost Carlos Salcedo on 33 minutes when the defender was stretchered off with a shoulder injury after coming second-best in a tussle with Wood.
The New Zealand forward had the best of the early chances when he twice forced Mexico goalkeeper Alfredo Talavera into saves.
The Oceania champions took a shock lead when Clayton Lewis threaded his pass between two defenders to Wood, who coolly fired home on 42 minutes.
With the Kiwis’ tails up, Wood could have grabbed a second when he again got in behind the defence, but failed to control the ball as they took a one-goal lead into the break.
Mexico boss Osorio responded by bringing on Porto defensive midfielder Hector Herrera for the second half.
It resulted in a double chance as Javier Aquino forced New Zealand keeper Stefan Marinovic into a left-handed save, before Giovani dos Santos fired over.
At the other end, Wood squandered a one-on-one with Talavera and moments later Mexico were level.
Aquino broke down the left flank and passed to Marco Fabian, who squared for forward Jimenez to fire home.
Peralta hit the winner in the 72nd minute when Aquino pulled the ball back for the 33-year-old to find the net.
But the Kiwis kept battling and with Mexico allowing them plenty of space to attack, midfielder Ryan Thomas clattered the woodwork with five minutes to go.
New Zealand defender Tommy Smith then cleared Jimenez’s shot off the line in the dying stages, just before a mass brawl broke out after Herrera clashed with Thomas.
Referee Bakary Gassama consulted the video assistant referee and Herrera was booked after a delay of over four minutes.
beIN SPORTS, the biggest show