Tech 3's Cal Crutchlow claimed the final front row spot, narrowly denying the satellite Hondas of Stefan Bradl and Alvaro Bautista.
Jonathan Rea, in his MotoGP qualifying debut, meanwhile sealed ninth, just 1.5 seconds down on Pedrosa.
With the field starved of mileage during three practice sessions in which conditions made running almost futile, the opening half of qualifying was unsurprisingly devoted to testing runs and garage feedback rather than chasing times.
That all changed in the final minutes however as times tumbled and the top spot changed hands several times per lap.
With three minutes to go Bradl held provisional pole for his LCR outfit, which is based in San Marino.
Crutchlow snatched pole less than forty seconds later however, before lowering his own benchmark next time around by dipping to a 1m34.001s.
He ran wide on his final lap though, meaning he was powerless to respond if any of his rivals improved.
Fittingly for such a breathless conclusion, he did not have to wait long. Moments after crossing the line, Crutchlow was followed by the works bike of Lorenzo, who set a new overall best of 1m33.875s.
Pedrosa looked well short of matching that but found massive time in the final sector to spring a surprise and claim pole by just 0.018s.
In what was a remarkably close session, Bautista in fifth was still within half a second of Pedrosa's time, while Valentino Rossi - enjoying a strong qualifying in what will be his last race for Ducati on home soil - was 0.7s back in sixth.
Andrea Dovizioso finished seventh ahead of Ben Spies, who had been running well early on but missed the final 10 minute flurry when he dropped his bike at Turn 1.