Jorge Lorenzo snatched pole at Motegi from team-mate Valentino Rossi as the MotoGP world title leaders served up an astonishing battle in final qualifying at the Twin Ring circuit in Japan.
Rossi, who heads into Sunday's race with a narrow lead of 14 points over the Majorcan, found a sensational injection of pace in Q2 to push the red-hot pole favourite all the way.
In a gripping showdown, Rossi – who had trailed Lorenzo by up to eight tenths during free practice – was able to use his team-mate as a marker during the first time attack to hit the top in a Yamaha one-two before Andrea Iannone took up the running seconds later on the Ducati GP15, heading both factory M1s.
Bradley Smith came off at Turn 5 on his second lap after losing the front end and more misery was to follow for the British rider, who went down at high speed at the fast Turn 12 after switching to his second bike, bouncing through the gravel trap but fortunately getting to his feet quickly afterwards.
The Monster Yamaha Tech 3 rider had appeared on course to challenge for a top three spot at that point but eventually qualified on the third row in ninth place.
Meanwhile, Rossi kept up the pressure as the 36-year-old set a new pole record of 1m 44.222s to take provisional pole while Lorenzo pulled into the pits for a change of tyres.
Repsol Honda's Marc Marquez, who was clearly fighting the RC213V under braking at Turn 11, hauled himself into third place as Iannone went second.
Marquez's team-mate, Dani Pedrosa, surged up the leaderboard into fourth as Rossi held sway from Iannone and Marquez, with Andrea Dovizioso on the second factory GP15 fifth and Lorenzo now sixth as the double premier class champion ventured back out on track for his second time attack.
The Yamaha star produced a stunning lap to resume control at the top of the times, dipping into the 1m 43s bracket and lapping more than half-a-second quicker than the old pole record.
As Lorenzo pitted again in a three-run strategy, all eyes were on Rossi, who incredibly was under his team-mate's time in the opening sectors and maintained his breath-taking pace to re-take pole as Marquez jumped into second.
The onus was on Lorenzo, who would have one final attempt to reverse the positions with his team-mate at the top and in a sensational end to Q2, the 28-year-old had enough in hand to snatch pole away from Rossi by only 0.08 seconds in one of the most dramatic qualifying sessions witnessed in recent years.
Lorenzo's final time of 1m 43.790s bore testament to how hard he had been pushed by surprise package Rossi, who cut a confident figure in parc ferme afterwards.
Marquez held on for third to complete the front row, a huge 0.426s behind the Yamaha pair, while Ducati duo Dovizioso and Iannone head up the second row and are joined by Pedrosa in sixth, who was almost eight tenths behind Lorenzo.
Aleix Espargaro was seventh fastest on the Ecstar Suzuki GSX-RR ahead of LCR Honda's Cal Crutchlow, with Smith completing row three after a miserable day for the satellite Yamaha rider.
Rookie Maverick Vinales (Suzuki), Pol Espargaro on the second of the Monster Yamaha Tech 3 machines and Scott Redding (EG 0,0 Marc VDS Honda) were the top 12.
Vinales and Redding sealed their passage into Q2, which was delayed slightly after Alex de Angelis' fall in FP4, after leading the times in Q1 respectively.
Stefan Bradl was 13th on the Aprilia ahead of Yonny Hernandez (Pramac Ducati) and wildcard rider Katsuyuki Nakasuga on the factory Yamaha M1.
Bradl narrowly missed the chance to progress into Q2 after an excellent effort in Q1, narrowly finishing behind Vinales and Redding.
Hector Barbera was the top Open class rider on the Avintia Ducati in 18th ahead of wildcard Takumi Takahashi (HRC Nissin Honda), with Eugene Laverty 20th ahead of his Aspar Honda team-mate Nicky Hayden and Jack Miller (LCR Honda).
1 Jorge Lorenzo
2 Valentino Rossi
3 Marc Marquez
4 Andrea Dovizioso
5 Andrea Iannone
6 Dani Pedrosa
7 Aleix Espargaro
8 Cal Crutchlow
9 Bradley Smith
10 Maverick Viñales
11 Pol Espargaro
12 Scott Redding