Jorge Martin breaks lap record to take pole at Italian MotoGP
Martin started strong in the second qualifying session and went fastest with an early time of 1:44.504 to better Franco Morbidelli's mark of 1:44.726, set minutes earlier in Q1.
Bagnaia finished second-quickest, with Aprilia's Maverick Vinales completing the front row.
"It feels really good, we worked a lot yesterday evening," Martin said after the race.
"This lap time is amazing. I think for tomorrow, we're in a strong position."
Bagnaia was given a three-place penalty on Friday after being involved in an incident with Alex Marquez, in which he was found guilty of having impeded the Gresini Racing rider.
The Italian, who will start second in Saturday's sprint but will have to fight his way out of fifth place in Sunday's race, hit out at the penalty after qualifying, saying: "It's one of the greatest things I could do today, starting in the front row.
"This clown penalty is something useless, but today in the sprint it will be important to start well.
"We know our pace is very fast, so I think if we can lead in the first lap, we have a good advantage."
Gresini's Marc Marquez looked set to challenge for pole position with a scorching lap towards the end of the qualifying session, but he ended up in the gravel after pushing a little too hard.
The Spaniard, third in the championship, finished fourth-quickest in the session.