Casey Stoner captured pole position for MotoGP's German Grand Prix as qualifying built to a scintillating crescendo.
Top spot changed hands time after time in the closing minutes, with seven riders all holding provisional pole as circuit conditions improved dramatically in the final stages.
It had looked like LCR Honda's Stefan Bradl would be set for a first MotoGP pole on home soil, the German topping the timesheets when the deluge hit and most riders pulled back into the pits with 20 minutes to run.
The rain abated however and those out on track began to improve, acting as a catalyst for a rush out of the pits and an incredible finish to the session.
Ducati's Nicky Hayden kicked off proceedings by going fastest with seven minutes to run, only to be immediately demoted by Bradl, Yamaha's Ben Spies and then Tech 3 Yamaha's Cal Crutchlow.
Hayden was soon back at the top of the timesheets, but as the two works Hondas also got up to speed the pole spot changed hands almost every time one of the seven came over the line.
With one minute to go the sequence was still being repeated. Hayden went fastest, only for Stoner to take it just before the chequered flag flew.
On their final laps Crutchlow, Dani Pedrosa (Honda) and then Spies all went top, but Stoner was still out on track and came round in a 1m31.796s to finally earn pole.
Spies and Pedrosa did enough to take second ahead of Crutchlow and Yamaha's Jorge Lorenzo, leaving Bradl sixth on the grid for his home grand prix.
Hayden meanwhile slipped to seventh, having been third with less than one minute on the clock.
The early torrential conditions caught out several riders, particularly at the treacherous Turn 12 where both Hector Barbera (Pramac Ducati) and Michele Pirro (Gresini FTR) fell heavily.