The two Mercedes opted for two warmup laps, with Hamilton second in line behind his team-mate.
In the final sector of his flying lap, Leclerc got close enough to the back of the seven-time world champion to receive a sizeable slipstream, helping him gain significant time in the long flat out run to the flag.
“It was quite a shit lap I thought,” the Monegasque joked.
“I mean, there were like two or three corners where I did mistakes but then of course I had the big tow from Lewis in the last sector, which helped me a little bit.
“Overall I think we will have been there, about top four anyway, without the slipstream, so it's a good day.”
The result is Leclerc's second pole in as many races, though last time out he failed to start after suffering a driveshaft issue on his way to the grid.
That was most likely linked to a late crash which ended qualifying in Monaco, though there are no such concerns this time around – at least not for Leclerc.
The slow corners in Monaco played to the strengths of the SF21, which many expected would be found out on the long front straight in Baku.
It's not proved to be the case, with both Ferraris showing promising pace throughout the weekend.
Leclerc, however, is reserved when it comes to his chances of holding on to top spot in the race.
“We've seen that in FP2, so it's going to be very difficult because here it's not like Monaco, they can overtake.
“I will try to do the best job possible and hopefully we can keep that first place but it's going to be difficult.”
The Azerbaijan Grand Prix gets underway at 22:00 AEST this evening.