Charles Leclerc joked "it was quite a s*** lap" after he clinched pole position for the Azerbaijan Grand Prix ahead of Lewis Hamilton and Formula One championship leader Max Verstappen.

In a qualifying session littered with crashes on Saturday, it was Ferrari's Leclerc who came out on top, recording a time of one minute and 41.218 seconds.

The frantic session on the streets of Baku saw four red flags raised, equalling the record for the most in qualifying, which was set ahead of the Hungarian Grand Prix in 2016.

Indeed, it was the fourth red flag which all but sealed Leclerc's pole, his second in a row after he started at the front of the grid in Monaco last time out – he is the first driver to take back-to-back poles this season.

World champion Hamilton struggled in practice, but was second when Yuki Tsunoda's crash into the barriers ended qualifying and came in a tenth of a second quicker than Verstappen, who had crashed out in the final practice session.

Leclerc was not best pleased with his efforts, but had no qualms about securing pole.

"It was quite a s*** lap I thought!" Leclerc, who set his fastest time with the help of a slipstream from Hamilton, joked to Sky Sports.

"There were like two or three corners where I did mistakes, but of course I had the big tow from Lewis in the last sector which helped me a little bit.

"But overall I think we would have been there or thereabouts for pole without the slipstream, so it's a good day. I did not expect to be as competitive as we were today. I was improving again [before] the red flag but it's like this, another pole, and I'm happy anyway."

Meanwhile, Hamilton was left to reflect on what he labelled a "monumental" result for Mercedes, with the team having struggled throughout the week – indeed, Valtteri Bottas will start in 10th on Sunday.

"We definitely weren't expecting that and this is such a monumental result for us because we've been struggling like you couldn't believe all weekend. You can see it," Hamilton said.

"We kept our composure. We've continued to have difficult discussions in the background and challenging one another, and just never taking no for an answer. We've moved around, made so many changes, over these two days. Just chasing our tail and it's been so difficult.

"It has been the biggest challenge in a long time. It has been a bit of a disaster."

Verstappen won in Monaco, with Red Bull aiming for consecutive race victories for the first time since 2014, but the young Dutchman could not hide his frustration with how the session panned out.

"It was just a stupid qualifying to be honest, but it is what it is," he said. "It's a street circuit so these things can happen, our car is strong so hopefully tomorrow we can score good points."

Pierre Gasly was in fine form during practice and took the momentum into qualifying, clinching fourth on the grid, while Carlos Sainz completed an impressive showing from Ferrari by coming in fifth.

The day ultimately belonged to Leclerc, who will be hoping for better luck than he had in Monaco, when a mechanical issue meant he could not build on his pole position and had to drop out of the race.

PROVISIONAL CLASSIFICATION

1. Charles Leclerc (Ferrari) 1:41.218
2. Lewis Hamilton (Mercedes) +0.232s
3. Max Verstappen (Red Bull) +0.345s
4. Pierre Gasly (AlphaTauri) +0.347s
5. Carlos Sainz (Ferrari) +0.358s
6. Lando Norris (McLaren) +0.529s
7. Sergio Perez (Red Bull) +0.699s
8. Yuki Tsunoda (AlphaTauri) +0.993s
9. Fernando Alonso (Alpine) +1.109s
10. Valtteri Bottas (Mercedes) +1.441s