The North American side looked on course to reach the quarter-finals for the first time since hosting the World Cup in 1986 after Giovani dos Santos’ stunning strike broke the deadlock.
However, their resistance was broken just two minutes from full-time when Wesley Sneijder rifled home from the edge of the box, and they were left shell-shocked and heartbroken in the fourth minute of injury-time when substitute Klaas-Jan Huntelaar netted from the penalty spot to cap a miraculous turnaround.
Both sides struggled in the scorching heat in Fortaleza – the pitchside thermometer recorded a temperature of 38.8C – and chances were at a premium during the opening period.
Mexico were denied a penalty when Ron Vlaar appeared to catch Oribe Peralta in the face with a high boot, while Arjen Robben appealed for a spot-kick toward the end of the first half after he was sandwiched by Rafael Marquez and Hector Moreno.
However, the match exploded into life shortly after the interval when former Tottenham winger Dos Santos’ speculative left-footed effort from outside the box beat goalkeeper Jasper Cillessen.
Holland adopted a more direct style as the match wore on and substitute Huntelaar, who came on in place of captain Robin van Persie, made an impact as he nodded the ball into the path of Sneijder, who gratefully lashed the ball beyond the impressive Guillermo Ochoa.
And Huntelaar had his say once again when he coolly sent Ochoa the wrong way from 12 yards out after Marquez was penalised for upending Robben in the closing stages.
In the day's second tie, Group D surprise package Costa Rica beat Greece 5-3 on penalties
Costa Rica took the lead on 52 minutes through captain and former Fulham foward Bryan Ruiz, and although the Central American side had Fabio Duarte sent off soon after, Greece struggled to press home the advantage.
But Socratis Papastathopoulos drilled home in added time to make it 1-1 at full-time.
Then, after a goalless half-hour of extra-time, Theofanis Gekas missed from the spot to send Costa Rica through to the last eight.