The British driver seemed surprised when his team announced over the race radio that he had beaten three-time defending Formula One champion Sebastian Vettel.
Hamilton clocked 1 minute, 19.388 seconds, just ahead of Vettel's best lap of 1:19.426. Red Bull and Mercedes have combined to take all 10 poles this season.
Lotus driver Romain Grosjean, who was fastest in the final practice session, qualified third for his best grid position of the season.
The track temperature on the Hungaroring circuit reached 122 degrees and stifling temperatures are expected for the race on Sunday.