Down 1-0 with minutes remaining in the match, the Dutch found goals from Wesley Sneijder and Klaas Jan Huntelaar to overturn the Mexican lead.
Sneijder tied the match in the 88th minute, and Huntelaar scored from the penalty spot in the 93rd minute after Arjen Robben earned a penalty.
Giovani Dos Santos thought he had the winner when he gave Mexico the lead three minutes into the second half.
Heat was a major factor in the match, forcing FIFA to implement the first two cooling breaks at the World Cup.
The Netherlands will play either Costa Rica or Greece in the quarter-final.