The 24-year-old German clocked a best time of one minute 19.815 seconds, edging out Briton Lewis Hamilton of McLaren in the final seconds of the session.
Briton Jenson Button was third fastest in the second McLaren followed by Ferrari drivers Brazilian Felipe Massa and double champion Spaniard Fernando Alonso – the former out-qualifying his team-mate for the first time this season.
Australian Mark Webber took sixth in the second Red Bull ahead of Germans Nico Rosberg of Mercedes, Force India driver Adrian Sutil and Michael Schumacher in the second Mercedes.
Sauber driver Mexican Sergio Perez completed the top ten.
On warm but overcast day at the Hungaroring, temperatures reached as high as 23 degrees, that meant drivers were able to warm up their tyres more quickly than they had anticipated and were forced to post flying lap times with heavy fuel loads.
After a tense opening mini-session in Q1, Hamilton topped the times but out went Swiss Sebastien Buemi of Toro Rosso in 18th along with the three newer teams.
However, Buemi will serve a five place grid penalty and start in 23rd position, meaning places 18 to 22 will be filled by Lotus drivers Heikki Kovalainen of Finland and Italian Jarno Trulli, Virgin driver German Timo Glock, Hispania drivers Italian Vitantonio Liuzzi and Australian rookie Daniel Ricciardo.
Belgian Jerome D’Ambrosio of Virgin will start in 24th place.
Alonso topped the times in Q2 which saw Force India driver Paul Di Resta of Britain eliminated in 11th place ahead of Russian Vitaly Petrov of Renault.
Japanese Kamui Kobayashi of Sauber was 12th quickest followed by German Nick Heidfeld in the second Renault.
Brazilian veteran Rubens Barrichello of Williams was 15th ahead of Spaniard Jaime Alguesuari in the other Toro Rosso and Venezuelan Pastor Maldonado in the second Williams.