Jorge Lorenzo snatched the top spot away from MotoGP title rival Marc Marquez in the final moments of a thrilling first Aragon practice session.
Having come to his latest home race chasing a third consecutive race win, Lorenzo kept the pressure on points leader Marquez with a 1m49.753s lap as the chequered flag fell on Friday morning.
The Yamaha's time beat Honda man Marquez by just 0.008 seconds.
Earlier, Honda had filled the top four while Lorenzo made a slow start to the session.
But once Lorenzo got going properly, he immediately surged to the front. The first man to break into the 1m49s, he was half a second quicker than the pack for a spell.
Marquez closed in and then inched ahead, establishing a 0.082s advantage with a 1m49.761s lap.
It looked unlikely that there would be any further changes, before Lorenzo dug deep on his last run and stole first place back.
Marquez's Honda team-mate Dani Pedrosa improved his pace through the session and eventually got within 0.187s of the top spot in third.
Alvaro Bautista put his Gresini Honda fourth ahead of Valentino Rossi's Yamaha and the second satellite Honda of LCR rider Stefan Bradl.
Cal Crutchlow could only manage seventh, separated from Tech 3 Yamaha team-mate Bradley Smith by Ducati pair Andrea Dovizioso and Nicky Hayden.
The in-demand Aleix Espargaro was the fastest CRT rider in 12th, despite a late gravel visit, although he was only 0.2s faster than Hiroshi Aoyama, Claudio Corti and Hector Barbera.
Pramac's new recruit Yonny Hernandez was 18th in his first session on the prototype Ducati.
Newcomer Luca Scassa and returnee Damian Cudlin were 20th and 24th for Cardion AB and Paul Bird respectively.
Pos Rider Bike Time Gap Laps 1. Jorge Lorenzo Yamaha 1m49.753s 17 2. Marc Marquez Honda 1m49.761s +0.008s 19 3. Dani Pedrosa Honda 1m49.948s +0.195s 19 4. Alvaro Bautista Gresini Honda 1m50.219s +0.466s 18 5. Valentino Rossi Yamaha 1m50.499s +0.746s 18 6. Stefan Bradl LCR Honda 1m50.535s +0.782s 19 7. Cal Crutchlow Tech 3 Yamaha 1m50.575s +0.822s 18 8. Andrea Dovizioso Ducati 1m50.852s +1.099s 16 9. Nicky Hayden Ducati 1m51.020s +1.267s 19 10. Bradley Smith Tech 3 Yamaha 1m51.263s +1.510s 18 11. Andrea Iannone Pramac Ducati 1m51.331s +1.578s 18 12. Aleix Espargaro Aspar Aprilia 1m51.822s +2.069s 13 13. Hiroshi Aoyama Avintia FTR-Kawasaki 1m51.970s +2.217s 18 14. Hector Barbera Avintia FTR-Kawasaki 1m52.026s +2.273s 18 15. Claudio Corti Forward FTR-Kawasaki 1m52.122s +2.369s 18 16. Danilo Petrucci Ioda-Suter-BMW 1m52.168s +2.415s 19 17. Colin Edwards Forward FTR-Kawasaki 1m52.321s +2.568s 19 18. Yonny Hernandez Pramac Ducati 1m52.529s +2.776s 17 19. Randy de Puniet Aspar Aprilia 1m54.092s +4.339s 12 20. Luca Scassa Cardion Aprilia 1m54.537s +4.784s 14 21. Michael Laverty PBM-Aprilia 1m54.804s +5.051s 16 22. Bryan Staring Gresini FTR-Honda 1m54.843s +5.090s 19 23. Lukas Pesek Ioda-Suter-BMW 1m56.110s +6.357s 17 24. Damien Cudlin PBM-Aprilia 1m56.925s +7.172s 16