Flying Francesco Bagnaia blitzes lap record for Malaysian MotoGP pole
Spain's Martin will start alongside the Italian on the front row for the sprint later Saturday and in Sunday's race at Sepang despite crashing in the closing stages. He was unhurt.
Factory Ducati rider Bagnaia, who leads Martin by 13 points in the championship with three races left, secured his first pole since the Catalan GP in September.
Title-holder Bagnaia has seen Pramac's Martin close in in recent weeks in the championship battle.
"Considering the last period for sure it's one of the most important (poles)," said Bagnaia.
"Most of the lap times were incredible.
"Being back in pole position is fantastic and we have to be very positive for this afternoon."
Bagnaia delivered a masterclass in the closing stages of qualifying as the Italian blitzed through the Sepang circuit to set a new lap record of one minute and 57:491 seconds.
Martin, also on a Ducati, had minutes earlier shattered his own lap record after clocking 1:57.549, before he was trumped by his rival.
Martin flew off the tarmac in Turn 4 as he attempted to go even faster.
Enea Bastianini, on another Ducati, completes the front three, with Spaniard Alex Marquez in fourth and Luca Marini in fifth.
Marco Bezzecchi, who is still just about in the title fight, was sixth.