Ferrari's Charles Leclerc grabbed his third consecutive pole for the Azerbaijan Grand Prix in a nerve-jangling red-flag interrupted qualifying at Baku on Friday.

Leclerc and Red Bull's world champion Max Verstappen had posted identical times in the top 10 shoot-out before Leclerc produced a magical flying last lap to head the grid for Sunday's race.

Verstappen, edged out by less than two tenths of a second, leads his Red Bull teammate Sergio Perez by 15 points in the world championship going into the fourth race of the season.

Perez will start on the second row in Baku with the Ferrari of Carlos Sainz, fourth in qualifying, keeping the Mexican company.

Mercedes' Lewis Hamilton came fifth to fill the third row with Fernando Alonso in the Aston Martin.

For Leclerc, this was an unexpected moment of sunshine on the banks of the Caspian Sea after what he has described as "the worst start to the season ever".

After adding to his 2021 and 2022 poles at this challenging street circuit he said: "We came into the weekend thinking it would be great if we were in front of Aston and Mercedes in qualifying and at the end we are on pole, so it's a really good surprise.

"We must not forget, our race car is maybe still behind the Red Bull, so it will be difficult to keep the lead, but that's the target. And really, really happy with that lap."

Verstappen had taken charge after the first stab around the six kilometre circuit in the opening qualifying session from Leclerc as Zhou Guanyu spun.

"It's really tough around here to really put the whole lap together," said Verstappen, who won this race last year.

Nyck De Vries then planted his AlphaTauri's nose into the wall at turn three to bring out a red flag with 10 minutes of Q1 to go.

"Oh my god, urrrrgh!" was the Dutch rookie's reaction on the radio.

No sooner had qualifying restarted than it was stopped again with another red flag - Pierre Gasly ripping off the corner of his hastily repaired Alpine to the consternation of his garage who had replaced the power unit in less than two hours after the car caught fire in Friday's earlier practice.

"I'm sorry, I locked the front" he said after a Friday to forget.

As the stewards got to work again to remove the damaged car Verstappen complained over the team radio "The sun is becoming lower and lower, it's quite annoying".

The Red Bull team have proved they can work wonders over the years but tinkering with the earth's orbit could be beyond them.

The cars were back out again with seven minutes of the opening session remaining.

De Vries, Gasly, Kevin Magnussen, Nico Hulkenberg and Zhou were eliminated.

Verstappen led the time sheets into Q3 with the five failing to make it out of the second session including George Russell, narrowly pushed down to 11th by none other than his teammate Hamilton.

"Sugar," said Russell bitterly.

Leclerc was first out for the final tilt at pole as the shadows lengthened on the circuit.

Verstappen posted a 1:40.445s - amazingly matched by Leclerc before the man from Monaco broke the deadlock with his final throw of the dice.

The drivers are back Saturday morning for another qualifying session, this one for Saturday's sprint before the main event on Sunday.