In humid conditions at the Mandalika track on Lombok island, Pramac's Martin had set an all-time lap record before the Italian Ducati rider nicknamed 'The Beast' quickly smashed it with his own record lap of one minute 29.630 seconds.
Reigning champion Francesco Bagnaia was 0.082 seconds off the pace in fourth, as he plots his bid to overtake Martin in the riders' standings - he trails by 24 points with six race weekends left.
Bastianini and Gresini's Marc Marquez are 59 and 60 points behind Martin. Marquez finished seventh in the final practice session.
Redbull GasGas rider Pedro Acosta slid off the track but came back to place in the top 10 to make the second round of qualifying on Saturday.
Aprilia's Miguel Oliveira however was ruled out of the race weekend and left in doubt for next week's Japan MotoGP after fracturing his right wrist in Friday morning's free practice session.
That session was topped by Italian rider Franco Morbidelli, who finished third in the final practice.
The top 10 fastest practice times book their tickets for Saturday's second qualifying session, which shapes the first four rows of the grid.
This group are then joined by the two fastest riders from the first qualifying session.
Qualifying shapes the grid for both the sprint race on Saturday and the main event GP on Sunday afternoon, with a maximum of 37 points available.