Following a frenetic qualifying, which saw four red-flag periods, Leclerc edged out Hamilton by two tenths of a second in Baku with Max Verstappen third for Red Bull.
Yuki Tsunoda crashed out in the final moments of qualifying which prevented the grid from completing their final runs.
While Leclerc celebrated his second pole in as many races, Hamilton will hardly believe he will start Sunday’s race ahead of Verstappen.
Hamilton’s Mercedes team have been off the pace all weekend, but the seven-time world champion improved as qualifying progressed to start the sixth round on the front row.
“Wow, what an effort,” the Mercedes driver said to his team over the radio.
In contrast, Red Bull were stunned as Verstappen was unable to post his second lap of Q3 after Tsunoda crashed out at Turn 3 and Carlos Sainz also ran off the circuit, distracted by the Japanese driver’s collision.
Pierre Gasly is fourth for AlphaTauri with Sainz fifth and Lando Norris sixth. However, Norris faces a trip to the stewards after he remained out on track when the first red flag was issued.
“The lap was okay, but we definitely were not expecting that,” said Hamilton, four points behind Verstappen. “This is a monumental result for us because we have been struggling all weekend.”
Q1 took almost 40 minutes, rather than the scheduled 18 to complete, following two red-flag periods. First, Lance Stroll crashed out in his Aston Martin.
The Canadian driver hit the wall on the exit of Turn 15 with the impact ripping off his front wing.
Following an 11-minute delay, the session restarted but soon it was the turn of Antonio Giovinazzi to fall victim to the 15th bend when he also ended up in the barriers. The two drivers will line up at the back of the grid.
The delays allowed Williams to complete an engine change on George Russell’s car after he broke down in final practice, and the Englishman repaid their impressive efforts by progressing to Q2 and finishing 15th.
Q2 then came to a premature end following the day’s third red flag.
Daniel Ricciardo, who has endured a difficult start to life at McLaren following his off-season transfer from Renault, carried too much speed into the left-handed Turn 3. He crashed into the wall, sustaining serious damage to the front of his car, but the Australian was unharmed in the accident. He will line up only 13th for Sunday’s race.
The off-track animosity between Mercedes boss Toto Wolff and Red Bull team principal Christian Horner is providing an entertaining sideshow, and in the build-up to qualifying, the former called his rival a “windbag who wants to be on camera”.
Wolff’s comments came 24 hours after Horner told the Austrian to “keep his mouth shut” as the row over flexible wings intensified.
Mercedes believe Red Bull’s rear wing is handing them an illegal advantage. Countering Wolff’s argument, Horner claimed on Friday that the Silver Arrows could be bending the rules with both their front and rear wings.
“If I were Toto, with the front wing he’s got on his car, I’d keep my mouth shut,” said Horner. “If anything, it looks maybe a bit worse than ours.”
But in response to his Red Bull rival, Wolff told Sky Sports: “Christian is a bit of a windbag who wants to be on camera. It is easy to be punchy when you are on top of the timesheets but you should be a little bit more modest.”