Casey Stoner continued Honda's domination of its home Japanese MotoGP with pole position at Motegi, but only after a surprise challenge from Yamaha's Jorge Lorenzo.
Reigning world champion Lorenzo - just fifth throughout free practice - knocked the Australian from the top with just five minutes of the hour remaining.
However, Repsol Honda rider Stoner then fought back to claim his tenth pole of the season by 0.256sec, setting a new pole record on the resurfaced circuit in the process.
The Australian will start Sunday's race with a 44 point title lead over Lorenzo.
Stoner's team-mates Andrea Dovizioso (+0.524sec) and Dani Pedrosa (+0.699sec) were third and fourth, with Pedrosa sure to be disappointed after leading on Friday afternoon and holding pole for much of qualifying.
Like his Factory Yamaha team-mate Lorenzo, Ben Spies also produced an inspired ride, overcoming weakness from food positioning to take fifth on the grid. Gresini Honda's Marco Simoncelli completed row two and was the final rider within one-second of Stoner.
Fellow Italian Valentino Rossi will start as the top Ducati in seventh place (+1.2sec), with Suzuki's Alvaro Bautista eighth and Aspar's Hector Barbera the top satellite bike rider in ninth.
Rossi's factory Ducati team-mate Nicky Hayden, who had been the only rider to break Honda's top-four domination in free practice, could only manage tenth in qualifying (+1.496sec).
Hiroshi Aoyama will start his home grand prix for eleventh on the satellite spec Gresini RCV, with Monster Yamaha Tech 3 rookie Cal Crutchlow just 0.007sec slower in his first ever qualifying session at the track.
Pramac's Randy de Puniet separated Crutchlow from team-mate Colin Edwards, who suffered a rare fall on his way to 14th on the grid. Simoncelli was the only other crasher during the session.