The Spaniard's time of one minute 33.857 seconds was enough to clinch pole with the Yamaha of Jorge Lorenzo less than two hundredths of a second behind.
Pedrosa is currently 13 points behind compatriot Lorenzo in the MotoGP championship standings and securing pole gives him the chance to close that gap in San Marino.
Briton Cal Crutchlow, who had sat on provisional pole for much of the closing stages of the qualifying session, will start third for Monster Yamaha Tech 3.
Fourth place was taken by Stefan Bradl, with his fellow Honda rider Alvaro Bautista fifth and Ducati's Valentino Rossi sixth.
Rossi's Italian countryman Andrea Dovizioso will start from seventh with Ben Spires eighth, while Jonathan Rea and Nicky Hayden rounded out the top 10.