Jorge Lorenzo moved from fourth to first on his very final lap of a close MotoGP qualifying for the Japanese Grand prix at Motegi.
The Factory Yamaha star demoted title rival Dani Pedrosa by 0.246s, with Cal Crutchlow pushed from pole to third in the closing minutes after suspected technical problems.
Lorenzo's team-mate Ben Spies was another pole contender, but slipped off at the hairpin on his final run, leaving him fourth.
Alvaro Bautista and Andrea Dovizioso will join the Texan on row two for Sunday's race, with Pedrosa's team-mate Casey Stoner peaking at second place - with twelve minutes to go - before dropping back to seventh for his comeback race from injury.
While the hard front tyre looks certain for the race, most riders put in some early qualifying laps with the harder rear - hedging their bets should race day bring hotter temperatures - before switching to the favoured softer option.
Lorenzo fitted the 'white line' rubber just before the halfway stage of the hour, then put his Factory Yamaha back onto provisional pole ahead of Pedrosa - where he remained until team-mate Spies set the fastest lap of the weekend with 18 minutes remaining.
Tech 3 Yamaha's Cal Crutchlow used a new pole record to replace Spies at the top on the brink of the final ten minutes... but then ran straight on at turn one.
The Englishman, who also did well to save a big front-end slide, nevertheless kept a debut pole in his grasp until Pedrosa slung his factory RCV from fourth to first with four minutes to go.
But Pedrosa didn't improve on his last two laps, and there were fears that yellow flags for Spies' low-speed slip might ruin Lorenzo's chances, but the #11 M1 was moved just in time for Lorenzo to surge to his sixth pole of the year.
Lorenzo holds a 33-point advantage over Pedrosa heading into Sunday's race, which is round 15 of 18.
Joining Stoner on row three will be Stefan Bradl (LCR Honda) and Valentino Rossi, who was one-second from pole. Rossi, whose Ducati team-mate Nicky Hayden qualified tenth, had an electrical problem on his Desmosedici at the start of the session.
Wild-card Katsuyuki Nakasuga qualified his Yamaha in eleventh place, beating Pramac Ducati's Hector Barbera, top CRT riders Aleix Espargaro and Randy de Puniet, plus Cardion AB's Karel Abraham, who fell.
The returning Ivan Silva props up the 22-rider grid, just behind new Speed Master signing Roberto Rolfo.
1. Jorge Lorenzo
2. Dani Pedrosa
3. Cal Crutchlow
4. Ben Spies
5. Alvaro Bautista
6. Andrea Dovizioso
7. Casey Stoner
8. Stefan Bradl
9. Valentino Rossi
10. Nicky Hayden
11. Katsuyuki Nakasuga
12. Hector Barbera
13. Aleix Espargaro
14. Randy De Puniet
15. Karel Abraham
16. Colin Edwards
17. Yonny Hernandez
18. Michele Pirro
19. Danilo Petrucci
20. James Ellison
21. Roberto Rolfo
22. Ivan Silva