Assen MotoGP: LIVE
In the closing minutes it looked like Stoner was destined to start only ninth on a grid headed by Pedrosa, as the track appeared set to remain wet until the chequered flag. But then the sun came out, quick times turned out to be possible after all, and Stoner delivered a stunning 1m33.713s lap to take pole as Pedrosa pushed their title rival Jorge Lorenzo's Yamaha back to third.
The changing weather was the main theme of the hour. With clouds gathering, everyone was keen to get an early fast lap in - as championship leader Lorenzo proved when he set his best time of the weekend, a 1m34.564s, just five minutes in. The Yamaha rider then improved to a 1m34.376s, which was beaten five minutes later by Pedrosa's 1m34.286s.
Rain arrived shortly afterwards, and although the track was never fully wet, it was enough to preclude quick times for a long while. When the first shower passed, Ben Spies and Alvaro Bautista managed to throw in quick laps that moved them into the top five but then the rain returned once more.
It looked like the session was settled, and at that stage Stoner had only put in a time good enough for ninth. But he was the first to take a chance on the track having dried again in the last four minutes, and he immediately jumped to third, before blitzing his rivals with a 1m33.713s next time around.
Pedrosa and Lorenzo were left to battle over second, with the Honda rider taking it by 0.173 seconds as he lapped 0.115s shy of Stoner's pace.
Moto2 champion Stefan Bradl claimed his best MotoGP qualifying position yet in fourth place for LCR Honda, ahead of Cal Crutchlow - who jumped up the order for Tech 3 Yamaha on his last lap.
Spies (Yamaha) fell back to sixth, with Crutchlow's team-mate Andrea Dovizioso seventh and Bautista (Gresini Honda) crashing at the end of the session and dropping to eighth.