Marc Marquez snatched his ninth-straight MotoGP German Grand Prix pole by just 0.025 seconds from Danilo Petrucci with a new lap record of 1:20.270s.
Marquez came into qualifying having not topped any of the four practice sessions run at the Sachsenring, and crashed at the start of FP4 at Turn 1.
Despite this, the Honda rider shot to the top of the pile straight away in Q2 with a 1:20.953s, though Jorge Lorenzo guided his Ducati to a 1:20.443s to move ahead of him.
Yamaha's Maverick Vinales forced both back a spot soon after by going 0.002s quicker than Lorenzo, while Marquez was unable to move up the order further on his second run.
With three minutes remaining, Pramac's Petrucci – who only had one bike at his disposal after his second GP18 expired at the end of FP4 – shadowed Lorenzo around for a lap to take provisional pole ahead of the Spaniard with a 1:20.295s.
Marquez's third run began with a moment on the way into the Omega corner, and missed out on top spot by just 0.014s.
Setting a personal best second sector on his final lap, Marquez narrowly tipped the balance in his favour across the rest of the lap to steal his third pole of the season with a new circuit record of 1:20.270s.
Petrucci was denied his maiden pole for a second year in succession at the Sachsenring by just 0.025s, with Lorenzo completing the front row.
Vinales will head up row two ahead of Q1 pacesetter Andrea Dovizioso on the sister factory Ducati and Yamaha team-mate Valentino Rossi.
Cal Crutchlow edged ahead of Andrea Iannone to secure eighth, while Alvaro Bautista – who crashed at Sachsen Kurve at the end of Q2 – Dani Pedrosa, Alex Rins and Q1 graduate Takaaki Nakagami completed the top 12.
Aleix Espargaro was just 0.009s outside of a place in Q2 having topped the first session briefly, though will drop to 19th due to a six-place grid penalty awarded to him for impeding Marquez in FP3.
A further 0.090s behind the Aprilia rider was Tech3's Johann Zarco, who registers his worst Saturday result of the season in 14th ahead of Pramac's Jack Miller.
KTM duo Pol Espargaro and Bradley Smith, the sister Tech3 machine of Hafizh Syahrin and Avintia's Tito Rabat will all move up a spot along with Zarco and Miller courtesy of Espargaro's penalty.
Marc VDS stand-in Stefan Bradl was two tenths clear of temporary team-mate Tom Luthi and will line up from 21st for his first MotoGP start since the 2016 Valencia Grand Prix.