The reigning world champion sealed the top spot from Aprilia's Maverick Vinales with a lap in 1:28.539s to knock the Spaniard off the top spot by 0.037s.
Brad Binder made it three different manufacturers on the front row as he took third to earn a front row start for KTM at their home round of the championship, with the leading trio separated by only 0.114s.
Vinales set the pace after the first time attacks with a 1:28.907 to lead Bagnaia, Fabio Quartararo and Binder.
In the final pole runs, Vinales improved to 1:28.576s before running off the track and into the gravel at Turn 4.
Bagnaia jumped to third ahead of Miller and then cliched pole from Viñales on his next lap, heading up the front row at a circuit where Ducati has only been beaten twice in nine races since the Red Bull Ring returned to the calendar in 2016.
Australia's Jack Miller, who progressed to Qualifying 2 after topping Q1 earlier, was fourth on the second of the factory Red Bull KTM machines and is joined on the second row by Silverstone Sprint winner Alex Marquez (Gresini Ducati) and Luca Marini (VR46 Ducati), who was second fastest in Q1 behind Miller.
Marco Bezzecchi, fastest on Friday, could only manage seventh on the VR46 Ducati, 0.369s down on Bagnaia, with Miguel Oliveira (RNF Aprilia) and Quartararo on the Monster Energy Yamaha completing the third row.
Johann Zarco was 10th on the Pramac Ducati ahead of British Grand Prix winner Aleix Espargaro, whose session was derailed after his fall at Turn 3.
Jorge Martin, second in the championship and 41 points behind Bagnaia, was 12th on the Pramac Ducati while Pol Espargaro – who received a three-place grid penalty for impeding Marc Marquez in practice on Friday – was 13th on the GASGAS Tech3 KTM. The penalty only applies to Sunday's main race and not the Sprint.
Spaniard Martin was left frustrated after his best lap was cancelled for exceeding the track limits.
Marquez was 18th on the Repsol Honda behind team-mate Joan Mir in 16th, while Japan's Takaaki Nakagami was 19th on the LCR Honda.
Enea Bastianini, last year's pole man, was 14th on the Lenovo Ducati.
Prior to qualifying, Binder was fastest in Practice 2 from Bezzecchi and Vinales, although the session had no impact on seeding for qualifying, which was decided in Friday's Practice 1.