It was the departing Stoner who kicked off a frantic 10-minute pole shoot-out in which Cal Crutchlow's Tech 3 Yamaha was also a factor.
For a while it seemed the Australian's 1:31.568s would hold. It featured a mighty final sector sufficient to deny Pedrosa, Crutchlow and Lorenzo several times even when all three had been up over the first three splits.
Lorenzo eventually bested Stoner with seven minutes to run, only for Stoner to once again seize control with a new benchmark two minutes from the end.
The drama was not finished however, as Pedrosa bolted to pole with a new Valencia record of 1:30.844s, eclipsing Valentino Rossi's 2006 mark.
Lorenzo was still out on track, and while he ultimately could not touch Pedrosa, he was able to do enough to demote Stoner into third.
Having also been in the mix until Pedrosa's late rally, Crutchlow had to settle for fourth and a share of the second row alongside LCR Honda's Stefan Bradl and his Tech 3 stablemate Andrea Dovizioso.
Ducati's Nicky Hayden was seventh, four spots ahead of team-mate Rossi in the Italian's final qualifying session for the team.
Alvaro Bautista, Hector Barbera and CRT rider Aleix Espargaro managed to split the pair.
As well as marking Stoner's final qualifying session, it was also the last before the qualifying format undergoes major changes for next year.
VALENCIA GP QUALIFYING
1-Dani Pedrosa 1:30.844
2-Jorge Lorenzo +0.351
3-Casey Stoner +0.584
4-Cal Crutchlow +0.668
5-Stefan Bradl +0.913
6-Andrea Dovizioso +0.951
7-Nicky Hayden +1.659
8-Alvaro Bautista +1.741
9-Hector Barbera +1.761
10-Aleix Espargaro +1.990