Giovanni Dos Santos gave Mexico the lead in the 48th minute and the Mexicans looked destined to reach their first quarter-finals since 1986 until Wesley Sneijder levelled two minutes from time and Huntelaar converted the penalty in time added on.
Dos Santos, who had two efforts controversially ruled out for offside in the win over Cameroon, struck with a sweet left-footed shot from outside the area in the 48th minute.
The Mexicans needed more heroics from goalkeeper Guillermo Ochoa, one of the stars of the finals so far. He pulled off several saves including a remarkable reflex stop from a point blank volley by Stefan de Vrij in the 57th minute.
However, he was helpless to stop Sneijder's piledriver and then could not prevent Huntelaar, who came on for captain Robin van Persie, from slotting the ball into the bottom left corner.