Perez nabbed pole on his first Q3 run as team-mate Max Verstappen made a mistake and aborted his lap, with Perez leading Aston Martin driver Fernando Alonso and Ferrari's Carlos Sainz.
Leclerc then crashed on the second run, bringing out a red flag that ended the session without anyone getting a second lap on the board, locking Perez in for pole.
The result came as a surprise to the Mexican, who had been struggling for pace compared to his team-mate and the Ferraris until that point.
In Q1 Perez was third 0.350s behind Verstappen, while in Q2 Perez dropped to fifth over half a second in arrears. In FP3 he had also been half a second off the Dutchman.
"I think it's been my worst weekend up to qualifying, really," he said.
"I just couldn't figure out how to pull those tenths that I was missing all the time to Max and to the Ferraris. I was just resetting everything.
"We did a small change into qualifying and everything became more alive. And I think with this tarmac we were just playing a bit with the tools, and we put the lap in when it mattered."
Source: Autosport