Lewis Hamilton claimed pole position for the Austrian Grand Prix, bouncing back from tyre blistering problems in final practice to top a rain-affected and dramatic qualifying session.
The drivers began Q3 at the Red Bull Ring on intermediate tyres after rain fell heavily in Spielberg at the end of Q2, but everyone had to switch to dry tyres for the last few minutes as the circuit conditions improved.
Hamilton ended the session 0.543 seconds quicker than Mercedes team-mate Nico Rosberg, but Rosberg will drop to seventh thanks to a grid penalty for changing his gearbox after a crash in final practice.
Nico Hulkenberg's Force India was the first car to switch to slicks in Q3 and ended the session with the third fastest time, ahead of Sebastian Vettel's Ferrari, which also carries a five-place grid penalty.
Jenson Button was a superb fifth fastest for McLaren-Honda and will start third on the grid thanks to Rosberg's and Vettel's penalties.
Kimi Raikkonen was 0.001s slower than Button in the second Ferrari, just ahead of Daniel Ricciardo's Red Bull.
The Williams of Valtteri Bottas, Max Verstappen's Red Bull and the second Williams of Felipe Massa rounded out the top 10.
That rain during the final minutes of Q2 prevented Mercedes matching the Red Bull and Ferrari strategy of setting faster times on super-soft tyres, meaning they can start the race on those sets.
Mercedes tried to respond after it used ultra-softs at the beginning of Q2, before the rain came, but the track was too wet when it sent its cars out on super-softs, so Hamilton and Rosberg will start on the less suitable softest compound.
The bad weather also protected Button from possible elimination, as he made Q3 for the first time since the 2014 Abu Dhabi GP by squeaking ahead of Esteban Gutierrez's Haas, which finished the session 11th fastest.
Manor's Pascal Wehrlein starred with the ninth best time in Q1, before going 12th fastest in Q2 - equalling Manor's best qualifying result in F1.
Romain Grosjean ran off track during his first run in Q2 on old tyres, and the subsequent rain condemned him to 13th on the timesheet, 0.150s adrift of Wehrlein.
Fernando Alonso was a distant 14th in the second McLaren-Honda, after mistakenly doing his first Q2 run on old tyres.
He finished the session ahead only of the Toro Rosso of Carlos Sainz Jr and Sergio Perez's Force India, who both sat out Q2 due to engine and suspension failures respectively.
The climax to the first part of qualifying was heavily affected by two separate incidents for Toro Rosso.
First Daniil Kvyat crashed after suffering suspension failure over the exit kerb at Turn 8, which caused a red flag that meant rivals had to abort runs.
Then team-mate Sainz suffered his problem exiting the pits after the restart, which caused yellow flags and rendered the final minutes largely redundant.
However, Hulkenberg improved his time while the yellow flags were out, so his front-row start is under threat from an investigation into how much he backed off when passing the incident.
Sainz remained 11th fastest, while Renault pairing Kevin Magnussen and Jolyon Palmer stayed 17th and 18th, behind Alonso's McLaren.
Rio Haryanto ended up 19th fastest in the second Manor, improving under the yellow flags but not in the first sector and not by enough to gain any places.
Kvyat ended up 20th, narrowly ahead of the Saubers of Marcus Ericsson and Felipe Nasr, the latter of which also improved under the yellows but again not by enough to improve position.
(Penalties for Rosberg and Vettel applied)