In a close-fought final Q3 shootout at the Jeddah Corniche street circuit, Ferrari's Carlos Sainz led the way after the first round of attempts before being demoted by teammate Charles Leclerc, setting up a Ferrari front row for Sunday's race.
But Perez surprised the Ferrari duo by dipping 0.025s below Leclerc's time with his final effort.
With Perez' teammate Max Verstappen settling for fourth, the 32-year-old Mexican sealed his first F1 pole in 215 attempts.
Perez says his pole lap was "unbelievable" and doesn't think he could have gone any quicker on the high-speed street track.
"It took me a couple of races but what a lap, man, it was unbelievable," Perez grinned. "I can do 1000 laps and I don't think I can beat that lap. It was unbelievable."
Perez said he didn't expect to be able to beat the Ferraris in qualifying, making his first pole even more memorable.
"We were not really expecting too much with the Ferraris in qualifying," he added. "We were focusing mainly on the race hopefully we'll get them tomorrow."
Leclerc said he didn't expect Perez to beat his lap in the final seconds of Q3 and commended the Mexican's "incredible" effort.
"The lap felt good honestly, I am very happy with the lap," said Leclerc, who won last week's 2022 season opener in Bahrain from pole.
"Qualifying was all about just keeping it on track and not doing any mistakes, which would have been very costly. And then in Q3 in the second lap, I just went for it and I more or less put everything together.
"There's a bit here and there but I definitely did not expect Checo to come with that lap time, so congratulations to him. I'm pretty sure he did an incredible job today.
"It's another day tomorrow and hopefully we'll have a good start."
Qualifying was delayed after a nasty accident in Q2 for Haas driver Mick Schumacher, who smashed into the concrete walls at Turn 10 after losing control over the kerbs.
Schumacher was taken to the medical centre by ambulance, where initial checks didn't reveal any injuries. The German was still airlifted to a nearby hospital for precautionary examinations.