(Reuters) -Yamaha's Fabio Quartararo was awarded pole position for the Portuguese Grand Prix on Saturday after Ducati rider Francesco Bagnaia had his record-breaking lap cancelled due to a yellow flag infringement.
Bagnaia thought he had clinched the top spot for Sunday's race by smashing the Algarve International Circuit record with his lap of one minute 38.494 seconds.
However, the Ducati celebrations were ended because of the yellow flags brought out due to a crash for 2020 Portugal poleman Miguel Oliveira in the closing moments of the session.
The incident meant Quartararo, who was fastest throughout the day, secured the 11th pole of his premier-class career with a time of one minute 38.682 seconds, while Bagnaia slipped to 11th.
"It's a pole but doesn't feel like usual," Quartararo said.
"We saw that Bagnaia was extremely fast so I'm more happy about FP3 and FP4. The main goal was to start on the front row and we've achieved it."
Suzuki's Alex Rins climbed up to second, while championship leader Johann Zarco shrugged off an earlier crash to finish third.
Returning six-times MotoGP champion Marc Marquez was fastest in Q1 and will start his first race in nine months from the back of the second row in sixth place.
The Repsol Honda rider fractured his upper arm in the season-opening Spanish Grand Prix in July and did not race again all year.
Reigning world champion Joan Mir -- who followed Marquez through Q1 -- finished ninth on his Suzuki, while Oliveira was left 10th after his late crash.
Seven-times premier-class champion Valentino Rossi, who has yet to score a top-10 finish this season, struggled to impress once again as he finished 17th on his Petronas Yamaha.
In the closing stages of the final practice session, Pramac Racing's Jorge Martin was ruled out of the weekend after a brutal crash at the Turn 7 right-hander.
The session was red-flagged as the medical team attended to Martin, who was conscious and was carried off the track into an ambulance and taken to the medical centre.
"He has been brought to the hospital for further check-ups as there is a high probability of two small fractures," Pramac Racing said in a statement.
(Reporting by Hardik Vyas in Bengaluru; Editing by Hugh Lawson and Clare Fallon)