Another stunning final lap helped Lewis Hamilton to secure pole position at the Belgian Grand Prix ahead of Sebastian Vettel.
With the third qualifying session affected by rain, Paul di Resta appeared to be on course to claim his maiden pole with Force India as he was the first man to switch to inters.
His 2:02.323 was the best time for most of the session with Felipe Massa P2, but then the rain started to ease off and that allowed the other drivers back into the game.
With the chequered flag already out, Nico Rosberg was first to cross the line and he claimed provisional top with a 2:02.251, but he was soon replaced by Mark Webber (2:01.325) and Vettel (2:01.200).
Hamilton, though, was the final man on the track and he beat Vettel to pole with a 2:01.012, much to the delight of everyone in the Mercedes garage.
It was Hamilton's fourth P1 in a row after his fifth of the season following his successes at China, Silverstone, Germany and Hungary.
Di Resta finished fifth in the end while Jenson Button put in another good display for McLaren in the wet to claim sixth. The Lotuses of Romain Grosjean and Kimi Raikkonen and Ferrari duo Fernnado Alonso and Felipe Massa completed the top 10.
Earlier, Caterham's Giedo van der Garde and Marussia pair Jules Bianchi and Max Chilton caused an upset as they made it through to Q2 after gambling on the slick tyres late in Q1.
The trio advanced at the expense of Williams pair Pastor Maldonado and Valtteri Bottas and Torro Rosso's Jean-Eric Vergne and Daniel Ricciardo as well as Esteban Gutierrez from Sauber.
It was damp but not raining at Spa as Q1 started, with the prospect of showers soon. Pastor Maldonado was the first man out on track for Williams but failed to put a time on the board when he missed his braking up the hill into Les Combes. Toro Rosso's Jean-Eric Vergne thus registered the first P1 time at 2:08.447. This was soon whittled down by the teams as everyone came out to set a banker lap on Intermediate tyres.
Lewis Hamilton looked to have mastered the conditions with a P1 time of 2:07.008, followed by Nico Rosberg 2:06.865, Mark Webber 2:06.645, Sebastian Vettel 2:06.279, Fernando Alonso 2:06.209 and then back to the Mercedes cars again with Lewis Hamilton reducing his time to 2:04.618 and Nico Rosberg 2:03.883.
Mercedes had struggled in morning practice to get the rear tyres and the front tyres heating up together, but they had obviously got on top of the situation now, with many believing that they had been hiding their true pace. The plan with most teams was to put in steady laps on one set of Intermediates, then at the end of the session bolt on a new set of Inters for the final run.
Sebastian Vettel's engineer Rocky asked a very telling question - with the rain stopping and the track drying out, when he came in, did Seb want a set of new Intermediates or a set of the Medium slick tyres?
With five minutes left of the session it was the usual suspects filling up the bottom end of the timesheets. 15.Sutil, 16.Bottas, 17.Maldonado, 18.DiResta, 19.Bianchi, 20.Pic, 21.Van der Garde, 22.Chilton
This was all about to change as Marussia and Caterham gambled by putting their drivers on Pirelli Mediums. They had nothing to lose provided the drivers could keep their cars on the island.
The top of the timesheets started to look like a pinball machine with the drivers on the new Intermediates getting a huge speed advantage. Esteban Gutierrez put his Sauber into P2 just behind Rosberg. And then Pastor Maldonado jumped from P17 to P1 on his new set of Inters. Daniel Ricciardo slotted into P2 and then Valtteri Bottas took P2. The top teams started cascading down the timesheets.
Paul DiResta took P1 with a 2:02.338, Nico Hulkenberg smashed that with a 2:01.712, then Mark Webber took over with a 2:01.597. When Nico Rosberg wrested the P1 position from Webber, team-mate Lewis Hamilton was down in P16, Fernando Alonso was in P17 and Felipe Massa had fallen to P18. They were all on strong laps, though.
Hamilton took P1 with a 2:00.368 and then Alonso eclipsed that with a 2:00.190. Massa made himself safe with a P6. Right at the end of the session, though, the slick runners were beginning to hit their window of operation. Giedo van der Garde put his Caterham into P3 at the last moment as he, Bianchi and Chilton all escaped into the new and scary territory of Q2.
Out went: 17.Maldonado, 18.Vergne, 19.Ricciardo, 20.Bottas, 21.Gutierrez, 22.Pic. Jules Bianchi was a historic P11 and Max Chilton P16. The teams that had switched to new Intermediates early had tumbled down the timesheets, a fact exacerbated by Marussia and Caterham switching to the dry tyres which came good right at the end.
With no further rain it was straight onto dry tyres for Q2 and Mark Webber had an exploration with a set of the orange-walled Hard tyres. Nico Hulkenberg posted a 1:51.193 and then Webber undercut it with a 1:50.128.
The session was less chaotic as Q1 as the track got steadily faster with no rain. Alonso took over on top with a 1:50.085, reduced by a sliver to 1:50.083 by Mark Webber immediately behind. Kimi Raikkonen was the first driver into the 1:49s with a 1:49.323.
With threatening dark clouds around the circuit, Lewis Hamilton left it late to claim P2. With 3:50 left on the clock the positions most at risk were: 7.Sutil, 8.DiResta. 9.Massa, 10.Perez, 11.Hulkenberg, 12.Van der Garde, 13.Chilton, 14.Bianchi, 15.Rosberg (no time), 16.Vettel (no time).
Rosberg and Vettel were leaving it very late - indeed Rosberg didn't have a time with 0 seconds on the clock. Vettel predictably put his Red Bull at the top with a 1:48 second lap, as Nico Hulkenberg improved to P2. In the remaining time, nine drivers would put their car ahead of Hulkenberg.
Mark Webber re-set P1 at 1:48.641, bettered by Alonso with a 1:48.309. Remarkably Adrian Sutil claimed P5 with two purple sectors, the low downforce S1 and S3, which shows the Force India team will be hoping for it to be dry on race day. Hamilton moved himself back up to P4, Perez P8, Paul DiResta grabbed P4, while Kimi Raikkonen took over on top again with a 1:48.296. Massa took P6, Grosjean P5, Nico Rosberg P3 and then Jenson Button re-inserted himself in the top 10 with a P5.
This left Lewis Hamilton in a less-than-convincing P10 at the end of Q2 with no-one left out on track. So out went: 11.Hulkenberg, 12.Sutil, 13.Perez, 14.van der Garde, 15.Bianchi, 16.Chilton.
Marussia and Caterham resumed their normal places at the bottom, but they will all be starting from unfamiliar positions - with six or more cars behind them. Hulkenberg missed out on demoting the 4-times polesitter (in 2013) by just 0.021 of a second, the distance between himself and Hamilton.
The chaos started again minutes before the start of Q3 as rain started to fall round the circuit. Nine cars huddled at the end of the pitlane with Medium slick tyres on hoping to put in a lap before the rain slowed the circuit. It was important to be first on track. Nine went out, with the Red Bulls and Lotus cars at the front of the queue and the Ferraris and Jenson Button at the back.
Only one car didn't go out and that was Paul DiResta's Force India. DiResta and the team judged that there would be too much rain for slick tyres and with heavy rain falling, the best thing would be to get a banker lap in on Intermediate tyres. It was the right call.
All nine drivers realised that it was too wet around the lap and all duly filed into the pitlane and needed to be wheeled back into their garages to have tyres changed to Intermediates. Ferrari were brilliantly quick at getting Felipe Massa out onto the circuit, as it looked like the heavy rain would soon make it impossible to improve through the session. Thus Paul Di Resta would be quickest, Felipe Massa (next on track) would be second quickest and then whoever followed Massa third quickest, etc.Paul Di Resta delivered a 2:02.332 lap that would surely be his debut pole position. Felipe Massa struggled round for a 2:04.059 for P2 and then Mark Webber was home next with a 2:05 lap for P3 and Sebastian Vettel was fourth back and claimed P4.
The theory that getting out early was essential was blown away by Nico Rosberg who then jumped ahead of Massa for P2. Hamilton and Button both squeezed ahead of Mark Webber. So after the first laps it was: DiResta, Rosberg, Massa, Hamilton, Button, Webber, Grosjean, Vettel, Raikkonen, Alonso.
The BBC commentary team were already congratulating DiResta, who had returned to the garage, when the first glimmer that the order was going to be overturned came on the timing screens. The rain had stopped and drivers were putting in green (Personal Best) sector times. Then Nico Rosberg set a purple (Fastest) sector time in S2, the long and twisty middle sector.
Rosberg crossed the line and took provisional pole with a 2:02.251. At this stage Hamilton had been demoted well down the order and just about crossed the line to start a final lap. The Red Bulls were going faster. Webber's final lap was a good one and he claimed P1 with a 2:01.325, he crossed the line just yards ahead of Vettel who took P1 with a 2:01.200, and then seconds later Hamilton put Mercedes back in familiar territory with a 2:01.012 and P1.
It had been a heartbreaking and dramatic end to a sensational qualifying session. With changeable conditions expected for the race tomorrow, the grand prix could be equally as good. Fernando Alonso qualified in P9 but was certainly not ruling himself out of a potential win.
1 Lewis Hamilton Mercedes 2:01.012
2 Sebastian Vettel Red Bull 2:01.200 +0.188
3 Mark Webber Red Bull 2:01.325 +0.313
4 Nico Rosberg Mercedes 2m02.251 +1.239
5 Paul di Resta Force India 2:02.332 + 1.320
6 Jenson Button McLaren 2:03.075 + 2.063
7 Romain Grosjean Lotus 2:03.081 + 2.069
8 Kimi Raikkonen Lotus 2:03.390 + 2.378
9 Fernando Alonso Ferrari 2:03.482 + 2.470
10 Felipe Massa Ferrari 2:04.059s + 3.047
11 Nico Hulkenberg Sauber 1:49.088 + 0.792s
12 Adrian Sutil Force India 1:49.103 + 0.807
13 Sergio Perez McLaren 1:49.304 + 1.008
14 Giedo van der Garde Caterham 1:52.036 + 3.740
15 Jules Bianchi Marussia 1:52.563 + 4.267
16 Max Chilton Marussia 1:52.762 + 4.466
17 Pastor Maldonado Williams 2:03.072 + 2.882
18 Jean-Eric Vergne Toro Rosso 2:03.300 + 3.110
19 Daniel Ricciardo Toro Rosso 2:03.317 + 3.127
20 Valtteri Bottas Williams 2:03.432 + 3.242
21 Esteban Gutierrez Sauber 2:04.324 + 4.134
22 Charles Pic Marussia - no time
Saturday's Shots From Spa