Casey Stoner captured his first pole position of his MotoGP title defense as a late red flag produced a frantic finish to qualifying at Estoril.
Five riders were in contention in what became a thrilling pole battle, fought out between the works Hondas and Yamahas and Tech 3 Yamaha's Cal Crutchlow, who played a starring role.
For a long while it had seemed that Jorge Lorenzo's early benchmark might just be enough for pole, the Spaniard surviving repeated attempts from the other quartet to best his time.
With 12 minutes to run the complexion of the session changed as Randy de Puniet lost the front of his Aspar Aprilia at Turn 4 and slid into Colin Edwards, who fell heavily. Qualifying was red-flagged as medical crews attended to both riders. After a short break the session was restarted and Stoner made an emphatic start, claiming pole position on his very first flyer.
Still there a surprise in store as Crutchlow guided his satellite Yamaha to the top with a 1m37.289s.
Stoner had two laps to respond however: on the first he was under for much of the lap but fell away, while on the second he did enough to pip Crutchlow by just 0.101sec.
Pedrosa too was out and on his final tour managed to jump into second behind Honda teammate Stoner, with Crutchlow therefore third. It is the second time in three races he has started on the front row.
Lorenzo was unable to improve in the final minutes and will therefore line up fourth for the Portuguese Grand Prix, ahead of Yamaha team-mate Spies.
The Texan was plagued by bad luck, hitting traffic on at least two occasions when he was inside the pole time. He eventually had to settle for fifth.
Alvaro Bautista claimed the final spot on the second row for Gresini Honda, less than three hundredths of a second ahead of Andrea Dovisioso's Tech 3 Yamaha.
Hector Barbera finished as the fastest Ducati in eighth for Pramac, a similarly tiny margin ahead of Valentino Rossi on the works machine.
Aleix Espargaro (Aspar) not only claimed top CRT honours in 12th but also outqualified Karel Abraham on the satellite Cardion Ducati of Karel Abraham.
Espargaro's team-mate de Puniet did enough to qualify 14th despite his accident, while Edwards - whose participation in the race is in doubt after he landed heavily on his collarbone – was 18th fastest.
Pos Rider Team/Bike Time Gap
1. Casey Stoner Honda 1m37.188s
2. Dani Pedrosa Honda 1m37.201s + 0.013s
3. Cal Crutchlow Tech 3 Yamaha 1m37.289s + 0.101s
4. Jorge Lorenzo Yamaha 1m37.466s + 0.278s
5. Ben Spies Yamaha 1m37.723s + 0.535s
6. Alvaro Bautista Gresini Honda 1m37.917s + 0.729s
7. Andrea Dovizioso Tech 3 Yamaha 1m37.943s + 0.755s
8. Hector Barbera Pramac Ducati 1m38.006s + 0.818s
9. Valentino Rossi Ducati 1m38.059s + 0.871s
10. Nicky Hayden Ducati 1m38.253s + 1.065s
11. Stefan Bradl LCR Honda 1m38.265s + 1.077s
12. Aleix Espargaro Aspar Aprilia 1m39.353s + 2.165s
13. Karel Abraham Cardion Ducati 1m39.398s + 2.210s
14. Randy de Puniet Aspar Aprilia 1m39.586s + 2.398s
15. Yonny Hernandez Avintia FTR-Kawasaki 1m40.029s + 2.841s
16. Michele Pirro Gresini FTR-Honda 1m40.225s + 3.037s
17. Mattia Pasini Speed Master Aprilia 1m40.387s + 3.199s
18. Colin Edwards Forward Suter-BMW 1m40.964s + 3.776s
19. James Ellison Paul Bird Aprilia 1m41.394s + 4.206s
20. Danilo Petrucci Ioda-Aprilia 1m41.486s + 4.298s
21. Ivan Silva Avintia Inmotec-Kawasaki 1m41.490s + 4.302s