Lewis Hamilton denied Sebastian Vettel Hungarian Grand Prix pole in a superb battle at the end of qualifying.
Vettel seemed to have put himself out of reach with an incredible first flying lap in Q3 that was 0.8 seconds clear of the rest of the field.
But Red Bull had the advantage of still having fresh soft tyres for both Q3 runs, whereas its rivals were all saving their rubber for their final lap.
At first, Vettel remained too fast to catch, with final practice pacesetter Romain Grosjean getting closest in his Lotus.
Then Mercedes driver Hamilton produced a 1m19.388s to depose Vettel, and although the world champion was also improving his pace, he fell 0.038 seconds short.
That was far better off than his team-mate Mark Webber. Vettel's closest rival on Friday had a KERS failure early in qualifying.
Webber struggled through to Q3 but did not run in the final segment so will start 10th in the second Red Bull.
Grosjean held on to third, joined on row two by Hamilton's team-mate Nico Rosberg.
Ferrari was not a factor in the pole fight, with Fernando Alonso fifth and Felipe Massa seventh.
Kimi Raikkonen was briefly on the provisional front row as he completed an early final run, but his Lotus ultimately fell to sixth.
Raikkonen's rival for a 2014 Red Bull seat Daniel Ricciardo maintained his strong recent form to put his Toro Rosso eighth, six places ahead of team-mate Jean-Eric Vergne.
Sergio Perez was the other Q3 contender in ninth, sticking to medium tyres rather than going for pole. His McLaren team-mate Jenson Button understeered to 13th.
Given his practice three engine problems, Esteban Gutierrez's Q1 departure was little surprise.
But Paul di Resta ending up 18th was a shock to both the Scot and Force India, left baffled by the performance of his final set of tyres.
Di Resta's team-mate Adrian Sutil missed out on the top 10 by just 0.042s and joins Nico Hulkenberg's Sauber on row six.
Caterham proved comfortably quicker than Marussia in the tail-end fight, while brief late-Q2 top-10 appearances by both Williams drivers proved deceptive as they were shuffled back to 16th and 17th.
Pos Driver Team Time Gap
1. Lewis Hamilton Mercedes 1m19.388s
2. Sebastian Vettel Red Bull-Renault 1m19.426s +0.038s
3. Romain Grosjean Lotus-Renault 1m19.595s +0.207s
4. Nico Rosberg Mercedes 1m19.720s +0.332s
5. Fernando Alonso Ferrari 1m19.791s +0.403s
6. Kimi Raikkonen Lotus-Renault 1m19.851s +0.463s
7. Felipe Massa Ferrari 1m19.929s +0.541s
8. Daniel Ricciardo Toro Rosso-Ferrari 1m20.641s +1.253s
9. Sergio Perez McLaren-Mercedes 1m22.398s +3.010s
10. Mark Webber Red Bull-Renault no time set
Q2 cut-off time: 1m20.545s Gap **
11. Adrian Sutil Force India-Mercedes 1m20.569s +0.791s
12. Nico Hulkenberg Sauber-Ferrari 1m20.580s +0.802s
13. Jenson Button McLaren-Mercedes 1m20.777s +0.999s
14. Jean-Eric Vergne Toro Rosso-Ferrari 1m21.029s +1.251s
15. Pastor Maldonado Williams-Renault 1m21.133s +1.355s
16. Valtteri Bottas Williams-Renault 1m21.219s +1.441s
Q1 cut-off time: 1m21.612s Gap *
17. Esteban Gutierrez Sauber-Ferrari 1m21.724s +1.374s
18. Paul di Resta Force India-Mercedes 1m22.043s +1.693s
19. Charles Pic Caterham-Renault 1m23.007s +2.657s
20. Giedo van der Garde Caterham-Renault 1m23.333s +2.983s
21. Jules Bianchi Marussia-Cosworth 1m23.787s +3.437s
22. Max Chilton Marussia-Cosworth 1m23.997s +3.647s
107% time: 1m25.974s
* Gap to quickest in Q1
** Gap to quickest in Q2