Marc Marquez deposed Jorge Lorenzo for the top spot by just one thousandth of a second in the dying moments of MotoGP practice three in Qatar.
Having also been quickest in second practice earlier on Friday, Honda's new signing Marquez will go into Saturday's final practice and qualifying as a sure-fire contender for pole.
Until Marquez's eleventh-hour surge to the front, most of the interest had been in the battle to secure the final top-10 places on the first weekend of MotoGP's qualifying shake-up.
Under the new system, pole is decided in a 12-bike shootout known as QP2. The fastest 10 riders on combined practice times proceed straight into this session, but the rest must battle it out in QP1 for the two final places in the last segment.
Pramac Ducati duo Andrea Iannone and Ben Spies ended up being the two prototype riders left among the CRT pack in the QP1 runners.
Both had nosed into the top 10 in the closing stages only to be edged back as the likes of Nicky Hayden, Stefan Bradl and Alvaro Bautista improved just in time.
CRT star Aleix Espargaro did his best to pull off some giantkilling, but was a tenth shy of Spies.
At the front, Cal Crutchlow spent a brief period in front before fellow Yamaha rider Lorenzo turned in his 1m56.085s halfway through.
Marquez drifted as low as eighth at one stage before surging to a safe fourth.
But the Honda rider was not finished yet. As the chequered flag flew, Marquez crossed the line with a last-gasp 1m56.084s, just 0.001s ahead of Lorenzo.
He then went off the road in traffic on his slowing down lap, slithering through the gravel and continuing.
Behind Crutchlow, Valentino Rossi took fourth on the second works Yamaha, followed by Andrea Dovisioso's Ducati and the muted Dani Pedrosa's Honda.
The only notable problem was Claudio Corti pulling off with early engine problems on Forward's FTR-Kawasaki.
Pos Rider Team/Bike Time Gap 1. Marc Marquez Honda 1m56.084s 2. Jorge Lorenzo Yamaha 1m56.085s + 0.001s 3. Cal Crutchlow Tech 3 Yamaha 1m56.326s + 0.242s 4. Valentino Rossi Yamaha 1m56.416s + 0.332s 5. Andrea Dovizioso Ducati 1m56.417s + 0.333s 6. Dani Pedrosa Honda 1m56.502s + 0.418s 7. Alvaro Bautista Gresini Honda 1m56.572s + 0.488s 8. Nicky Hayden Ducati 1m56.670s + 0.586s 9. Bradley Smith Tech 3 Yamaha 1m56.901s + 0.817s 10. Stefan Bradl LCR Honda 1m56.984s + 0.900s 11. Andrea Iannone Pramac Ducati 1m57.169s + 1.085s 12. Ben Spies Pramac Ducati 1m57.308s + 1.224s 13. Aleix Espargaro Aspar Aprilia 1m57.420s + 1.336s 14. Hector Barbera Avintia FTR-Kawasaki 1m57.956s + 1.872s 15. Yonny Hernandez PBM Aprilia 1m58.211s + 2.127s 16. Randy de Puniet Aspar Aprilia 1m58.396s + 2.312s 17. Colin Edwards Forward FTR-Kawasaki 1m58.863s + 2.779s 18. Karel Abraham Cardion Aprilia 1m59.180s + 3.096s 19. Hiroshi Aoyama Avintia FTR-Kawasaki 1m59.212s + 3.128s 20. Danilo Petrucci Ioda-Suter-BMW 1m59.755s + 3.671s 21. Bryan Staring Gresini FTR-Honda 1m59.758s + 3.674s 22. Lukas Pesek Ioda-Suter-BMW 1m59.837s + 3.753s 23. Michael Laverty PBM-Aprilia 2m00.080s + 3.996s 24. Claudio Corti Forward FTR-Kawasaki 2m00.439s + 4.355s