Sergio Perez has taken the second pole of his F1 career following a dramatic session in Saudi Arabia that saw Oscar Piastri ninth best.
Perez headed Charles Leclerc and Fernando Alonso at the end of the session while Max Verstappen was eliminated in Qualifying 2 with a driveshaft issue.
Piastri meanwhile exceeded all expectations to set the ninth best time while McLaren team-mate Lando Norris brushed the wall to end qualifying early.
Alex Albon kicked off the session with the first flying lap, a 1:30.167s which was soon bested by team-mate Logan Sargeant with a 1:29.721s.
Having missed Free Practice 3 after Scuderia AlphaTauri completed a power unit charge, Nyck de Vries had a spin at Turn 1 as he began his first push lap.
The Dutchman lost it under braking, the rear coming around and sending him into the run-off area in a moment that looked more systems fault than driver error.
Sargeant's best was deleted for track limits at Turn 27 though, in reality, it proved to be the pit entry line.
That left Nico Hulkenberg fastest with a 1:29.875s with Leclerc.
The two Red Bulls then showed their hand with Perez going 0.6s faster than Hulkenberg and Verstappen a full 0.5s quicker still with a 1:28.761s.
Piastri's first timed lap saw him eighth fastest, a 1:30.124s proving 0.3s better than team-mate Norris.
The Brit had brushed the wall at the apex of the final turn, swiping the front left wheel on the barrier before promptly returning to the pits.
It proved a costly error as the damage could not be repaired before the segment concluded.
Fernando Alonso had a spin at Turn 2 after asking too much from the rear end on exit to leave the Spaniard without a time with seven minutes to run.
Next time around, the Aston Martin driver improved to clock the fourth-best time at 1:29.404s.
Sargeant found himself pointing the wrong way at Turn 23 to draw a brief double yellow.
The American lost the Williams at Turn 22 to slide sideways over the kerbing at Turn 23 before pulling up just short of the concrete wall.
Piastri found himself on the bubble as the chequered flag waved.
He was quickly pushed into it as others improved though the Australian was on a final flying lap.
That netted a 1:29.706s to shoot up to 11th to progress to the next phase of qualifying.
Sargeant's session ended without a representative lap as he stopped on track having clouted the kerbing heavily while on his final flying lap.
Mercedes sent its pair out on a set of used soft tyres for their first run as Qualifying 2 began.
Zhou Guanyu was the first to set a time in the session, but it was Alonso who laid down the first proper marker.
The Aston Martin driver recorded a 1:28.757s, more than 0.5s faster than he'd managed in Qualifying 1.
Verstappen had a moment on his first flying lap but then slowed next time around reporting an engine problem with his Honda.
The Dutchman was pushing on before the revs suddenly increased on approach to Turn 13, suggesting a transmission issue.
He limped home as Perez went second fastest, 0.117s slower than Alonso had managed.
Back in the garage, there was frantic activity on the rear of Verstappen's car as the two-time world champion climbed from his car.
Piastri improved to seventh best as the chequered flag waved, dropping only to ninth to book his place in Qualifying 3 for the first time in his career.
Perez topped the segment from Alonso and Leclerc, while knocked out were Nico Hulkenberg, Guanyu, Kevin Magnussen, Valtteri Bottas, and Verstappen.
Three drivers headed out on used tyres as the final phase as Qualifying 3 commenced, namely Esteban Ocon, Pierre Gasly, and Carlos Sainz.
Alonso kicked off proceedings with a 1:28.925s which quickly became second when Leclerc banked a 1:28.757s.
Running slightly out of sequence, Hamilton went third best with a 1:29.223s before Russell clocked the second fastest time with a 1:28.872s.
Perez moved the marker to 1:28.265s to move 0.5s clear of Leclerc who sat second fastest.
Leaving his first run even later was Piastri, who only started his first flying lap after five minutes.
The Aussie logged a 1:29.710s, a time on par with his Qualifying 1 lap and 0.4s down on that which propelled him into the session's final phase.
Sainz had his late lap ruined as it commenced as he rounded Turn 2 as Russell joined the track from the pit lane.
The Mercedes was on the line the Ferrari ideally needed, delaying his progress and ruining his lap.
Piastri's second lap saw him climb to seventh, promptly bumped to eighth as Ocon improved.
Alonso rose to second best with a 1:28.730s only for that to become third when Leclerc improved.
Having started fast, Perez aborted his final lap as his position on pole was confirmed courtesy of those around him being unable to improve.
The Mexican will therefore start on pole, joined on the front row by Alonso as Leclerc falls to 12th courtesy of a 10-place grid penalty.
The Saudi Arabian Grand Prix begins at 20:00 local time on Sunday (04:00 AEDT Monday).