Mexico needed second-half goals by Benfica’s Jimenez and Peralta to grab victory over New Zealand in a bad-tempered match at Sochi.
Juan Carlos Osorio’s side now just need a draw against Russia in Kazan on Saturday to be sure of reaching the semifinals.
The Kiwis’ superb first-half display and Chris Wood’s shock goal rattled Mexico and a tense match boiled over with a mass brawl in the dying stages.
The match turned when Porto midfielder Hector Herrera came on for the second half and Mexico’s attacks started to flow.
The Oceania champion took a shock lead when Clayton Lewis threaded his pass between two defenders to Wood, who coolly fired home on 42 minutes.
After Herrera’s introduction, Javier Aquino forced New Zealand keeper Stefan Marinovic into a left-handed save, before Giovani dos Santos fired over.
Mexico equalised when Aquino broke down the left flank and passed to Marco Fabian, who squared for forward Jimenez to fire home on 54 minutes.
Peralta hit the winner in the 72nd minute when Aquino pulled the ball back for the 33-year-old to find the net.
Cristiano Ronaldo brushed aside his off-field problems by scoring the winner as Portugal edged out host Russia 1-0.
The results : Group A : Russia 0 lost to Portugal 1 (Ronaldo 8); Mexico 2 (Jimenez 54, Peralta 72) bt New Zealand 1 (Wood 42) .