Andrea Dovizioso beat Johann Zarco to MotoGP pole for the Japanese Grand Prix by 0.068 seconds, while champion-elect Marc Marquez was only sixth.
Marquez took over provisional pole with a minute remaining, but found himself shuffled off the front row in the space of a few seconds, while Dovizioso grabbed top spot at the death with a 1:44.590s.
The factory Yamaha duo of Valentino Rossi and Maverick Vinales set the early pace in Q2, with the former posting the benchmark of 1:45.804s, before Marquez – who had just one bike at his disposal after a late fall in FP4 – made his first play for pole with a 1:45.182s.
Honda stablemate Cal Crutchlow almost instantly demoted him, however, the Briton going top with a 1:44.909s to establish a two-tenth advantage over Ducati's Dovizioso.
Marquez returned to the top of the pile with a minute to go with a 1:44.889s, but was surprisingly beaten just seconds later by Pramac's Jack Miller, who posted a 1:44.727s.
Improvements from Crutchlow and Zarco saw Marquez pushed off of the front row in one fell swoop, and he would make no further impression on the top three as the session came to a close.
Miller's attempt to defend pole was foiled by a crash at Turn 5, while at the same time fellow Ducati rider Dovizioso usurped him with a 1:44.590s.
Zarco put this under threat with his final effort, but missed out on back-to-back Motegi poles by 0.068s, with Dovizioso securing his second pole of the season.
A 1:44.820s from early pacesetter Crutchlow was not enough to deny his former LCR team-mate Miller third, while a last-gasp 1:44.832s from Suzuki's Andrea Iannone pushed Marquez back to sixth – his worst qualifying result since Mugello.
Vinales put on a late charge for the front row, but ended up four tenths short in seventh ahead of the sister Suzuki of Alex Rins and Rossi.
Q1 graduate Alvaro Bautista completed the top 10 on his Nieto Ducati, with Dani Pedrosa [Honda] and home hero Takaaki Nakagami [LCR], who followed Bautista into Q2, filling out the rest of the top 12.
Bradley Smith came close to progressing into the pole shootout session having sat top of the Q1 timesheets with a 1:45.722s with just a minute remaining.
But the KTM rider fell victim to late improvements from Nakagami and Bautista to be denied graduation by just 0.066s, while teammate Pol Espargaro was just a further 0.020s adrift in 14th ahead of Pramac's Danilo Petrucci.
Franco Morbidelli looked set to join Honda stablemate Nakagami in Q2, but a late crash at Turn 12 ended his hoped and left the Marc VDS rider stuck in 17th.
Japanese wildcard Katsuyuki Nakasuga will start his seventh Motegi race with Yamaha from 20th, while Suzuki's Sylvain Guintoli will give the 2019 prototype GSX-RR its first race outing from 24th.