Ducati's Bastianini takes pole at Portuguese MotoGP ahead of Vinales
The pole was Bastianini's first since the Austrian Grand Prix in July 2022, with the Italian having struggled last season after joining Ducati in 2023.
"After a long time without the pole position, it's special today. It's the first one with Ducati. I'm happy because we improved since yesterday. It's only the first step, but we're happy," Bastianini said.
Bastianini clocked the best time of one minute, 37.706 seconds at the Algarve International Circuit to pip Aprilia's Maverick Vinales (29) and Pramac Racing's Jorge Martin (26).
Defending world champion Bagnaia had looked set to join Bastianini and Martin on the front row, but was bumped out of the top three by Vinales' late effort.
"Yesterday was very important to be on the bike, even though I felt a little sick, because we needed to modify the balance of the bike and get a better feeling from it," Vinales said.
"We found the balance, so we can push more. The lap times are there. Pretty happy. Of course, I'm not at my maximum, but it doesn't matter, this is racing. I feel prepared and I think we have a good chance."
Six-time MotoGP champion Marc Marquez (31), who moved to Gresini Racing from Honda for the 2024 season, crashed early in Q2 but was able to race back to the garage in time to hop on a spare bike and clinch eighth place.
Earlier on Saturday, Gresini's Alex Marquez (27) topped Q1 to move into Q2 along with GasGas Factory Racing Tech3 rookie Pedro Acosta (19).