Martin smashes lap record to storm to pole at Austrian Grand Prix
The Spaniard, who leads Bagnaia by three points in the championship standings, finished top with a time of one minute 27.748 seconds at the Red Bull Ring.
Martin, nursing a minor finger injury, will have the chance to stretch his lead in Saturday's sprint.
"It was difficult. Yesterday I had this cut on my finger that I thought was going to get better but this morning it was really painful. They just stitched me and at least I can ride," Martin said.
"While riding is not a big problem, I was able to work well in the morning, even if it's obviously disturbing me a little bit.
"But now I feel confident for the evening. (This is) a really nice track for me."
Bagnaia set the second-fastest time after dominating practice on Friday, with six-time MotoGP champion Marc Marquez, who is fourth in the championship, completing the front row.
Aleix Espargaro was fourth quickest, with Jack Miller, Maverick Vinales and Enea Bastianini in fifth, sixth and seventh, respectively.