PORTIMAO, Portugal — Lewis Hamilton edged out Mercedes teammate Valtteri Bottas to take pole position for the Portuguese Grand Prix on Saturday.

Having secured a record-extending 97th career pole, Hamilton can make Formula One history if he wins Sunday’s race with a 92nd win to move one clear of Michael Schumacher.

The runaway championship leader’s victory two weeks ago at the Eifel GP in Germany tied Schumacher’s F1 record of 91, in a season where he is odds-on to equal the German great’s record seven F1 titles.

Bottas had the leading time but did not create enough pressure on his last lap, and Hamilton squeezed through on his last attempt to beat him by .1 second.

“It’s amazing. I can’t tell you how hard that was today,” Hamilton said. “Valtteri has been so quick this weekend, he’s topped every session, so I’ve just been digging and trying to find that extra time. That last lap got better and better as I went through."

Mercedes has taken all 12 poles so far this season with Hamilton up 9-3 on Bottas, who looked like closing that gap but made a small mistake toward the end of his last lap.

“Mine was a decent lap, not perfect and it has been tricky to get really clear laps,” Bottas said. “I will do what I can from (second place).”

Red Bull driver Max Verstappen was .25 back in third place and Ferrari's Charles Leclerc qualified in fourth.

Former F1 champion Kimi Raikkonen was among the five drivers eliminated from Q1, the first part of qualifying, and four-time F1 champion Sebastian Vettel was slowest in Q2 and starts from 15th.

Right at the end of Q2, Daniel Ricciardo lost control of his Renault and went off into the gravel. With this rear wing damaged, the Australian driver was unable to take part in Q3 and starts 10th. Hamilton topped Q1 ahead of Verstappen, while Bottas led Q2 from Hamilton.

Montreal's Lance Stroll (1:17.667) was 12th in his Racing Point BWT Mercedes. Toronto's Nicholas Latifi (1:18.777) was 20th in his Williams Mercedes.

Earlier, Bottas topped the third and final practice session. After leading Friday's two practices, he was .03 seconds quicker than Hamilton and .16 ahead of Verstappen.

Hamilton damaged the front wing after sliding off into gravel on a track hosting its first F1 race that has caused numerous drivers problems because of its lack of grip. Leclerc again spun his car, as he had done on Friday.

Near the end of the session, a confused Leclerc asked his team over radio what was happening with his own, since he could hear Hamilton's radio messages. Leclerc was sixth fastest.

Meanwhile, Williams driver George Russell escaped with just a warning after going through a red light at the end of the pit lane.

There were mask-wearing fans sat in the stands around the undulating 4.6-kilometre (3-mile) circuit in Portimao, which has frequent elevation changes.

“The track is hardcore, there are places you can’t see where you are going. It really is one of the hardest circuits I’ve been too," Hamilton said. "The surface is strange. This is a very smooth surface and doesn’t work the tires the same as, say, Barcelona.”

It is the second new track on the coronavirus-hit calendar after the Tuscan GP in Mugello last month.

With one minute left, the session was stopped because of a drain cover that came loose when Vettel drove over it on Turn 14. It delayed the start of qualifying by 30 minutes while repairs were carried out.

Portugal last hosted a race in 1996, when three F1 champions made the podium after Jacques Villeneuve of Saint-Jean-sur-Richelieu, Que., won ahead of Damon Hill and Schumacher in Estoril.

___

More AP auto racing: https://apnews.com/apf-AutoRacing and https://twitter.com/AP_Sport