Lewis Hamilton snatched pole position for the Saudi Arabian Grand Prix on Saturday, boosting his hopes of staying on course for a record eighth Formula One world title.

Championship leader Max Verstappen was third fastest in the Red Bull after hitting a wall on his final flying lap on the tight Jeddah street circuit just as he appeared poised to unseat his rival.

Hamilton's Mercedes teammate Valtteri Bottas was second and will share the front row on Sunday.

"What a tough track this is. It's amazing what they've built, the speed and the pace around here is phenomenal," said Hamilton.

"It's a great result for the team and a great job by Valtteri -- he's the best teammate there's ever been in this sport."

For Hamilton, who has cut Verstappen's championship lead with successive wins in Brazil and Qatar, it was a fifth pole of the season and 103rd of his career.

Verstappen, who has an eight-point lead over Hamilton with just two races left, can claim his first world title on Sunday if he wins the race and Hamilton finishes outside the top six.

If not, the 2021 title battle will go down to the wire in Abu Dhabi next weekend.

Pole man: Lewis Hamilton in action in Jeddah Pole man: Lewis Hamilton in action in Jeddah Photo: AFP / ANDREJ ISAKOVIC

"I don't really understand what happened (on the final flying lap). I locked up a bit," Verstappen.

"P3 is disappointing but today did show that the car is quick around here so we'll see what happens tomorrow."

Ferrari's Charles Leclerc and Sergio Perez in the second Red Bull made up the top five for Sunday's race, the first to be held in the kingdom.

Pierre Gasly (AlphaTauri), Lando Norris (McLaren), Yuki Tsunoda (AlphaTauri), Esteban Ocon (Alpine) and Antonio Giovinazzi (Alfa Romeo) complete the top 10.

Securing pole capped a dramatic day for seven-time champion Hamilton.

He escaped a sanction for yellow flag incidents in Saturday practice after being summoned over an alleged failure to slow under double waved yellow flags, and for blocking the Haas of Nikita Mazepin.

However, the Mercedes star was cleared of any wrongdoing after the stewards admitted that a double-waved yellow light panel had been activated accidentally.

Mercedes were fined 25,000 euros for the second incident.

Verstappen was hit with a five-place grid penalty for failing to respect double-waved yellow flags during qualifying for the Qatar Grand Prix last month.