Huntelaar, who came on as a 76th-minute substitute, scored the winning goal from the penalty spot deep in injury time after Rafael Marquez brought down Arjen Robben in the area.
Giovani Dos Santos gave the Mexicans the lead in the 48th minute, but Sneijder equalized for the Dutch in the 88th.
Netherlands coach Louis van Gaal had said his team would have to battle the weather and Mexico in the steamy Arena Castelao, and in the end his players outlasted their opponents in the withering afternoon heat.
It was so warm in Fortaleza that referee Pedro Proenca called for cooling breaks in each half so players could rehydrate.
The Mexicans had conceded only one goal in three group matches and looked like they would keep another clean sheet until the late collapse.
It was heartbreak again for Mexico, which has now reached the second stage of the World Cup six straight times without winning. The last time the team made the quarterfinals was when it hosted the tournament in 1986.
Mexico goalkeeper Guillermo Ochoa had kept his team in the match with two great saves to preserve the lead in the second half, but he was beaten by Sneijder's powerful drive and guessed wrong when diving in an attempt to stop Huntelaar's penalty.
With his team a goal down and facing elimination, Van Gaal brought on attacker Memphis Depay and switched his team to the trusted 4-3-3 attacking formation.
The move worked as the Dutch poured forward and finally beat Ochoa.
It was the fourth straight win for the Netherlands at the World Cup after routing defending champion Spain 5-1 and beating Australia 3-2 and Chile 2-0 in Group B.
The Dutch will next face either Costa Rica or Greece in the quarterfinals on Saturday in Salvador.