Valentino Rossi protege Romano Fenati edged Livio Loi in a close qualifying battle to secure the first pole position of the new Moto3 season in Qatar.
Practice pacesetter Loi had commanded the timesheets for much of the session, setting an early benchmark of 2m06.520s to knock Fabio Quartararo from the spot.
Loi then lowered the bar by a further three tenths in the closing stages with a 2m06.178s, which looked to be enough to secure pole - until Fenati posted a time 0.047s faster after the chequered flag had fallen, a 2m06.131s, to deny his rival.
Behind Loi, Brad Binder made a late jump to third spot, just 0.114s off the pace, ahead of Quartararo, although the Frenchman will start on the front row owing to a three-place grid penalty for Binder.
That promotes Jorge Navarro - who suffered a crash at Turn 6 but got going again - to fourth on the grid for Sunday's race, ahead of Estrella Galicia teammate Aron Canet, the top rookie.
Niccolo Antonelli, another crasher, Enea Bastianini and Phillip Oettl make up the third row, as Red Bull Rookies champion Bo Bendsneyder was also penalised three places - dropping from eighth to 11th behind Joan Mir.