Casey Stoner snatched pole position at the end of an enthralling qualifying session for the German MotoGP at a soaking wet Sachsenring.

The reigning world champion overcame a technical problem, which saw him park his Repsol Honda, to become the fourth and final rider to occupy pole position after the chequered flag had been waved!

Yamaha's Ben Spies will start second after lapping 0.193s from Stoner, whose HRC team-mate Dani Pedrosa completed a front row covered by 0.285s.

Barring a dry Friday morning practice, the sessions since have all been wet and - unlike Saturday morning practice - there was no chance of a slick-tyre window emerging in qualifying.

But the rain did ease in the final ten minutes, triggering a constant tug-of-war for the top spot, which finally reached its climax with Stoner's 38th premier-class pole.

The last ten minutes saw pole change on a staggering 15 occasions, as seven different riders made at least one visit to the top: Jorge Lorenzo, Nicky Hayden, Stefan Bradl, Spies, Cal Crutchlow, Stoner and Pedrosa.

In total, pole time changed 29 times during the hour.

Row two of Sunday's race will be headed by Yamaha Tech 3 rider Crutchlow and Factory M1 star Lorenzo, now tied with Stoner for the world championship lead after his first turn Assen misery.

MotoGP rookie and home hero Stefan Bradl warmed the hearts of the drenched German fans by leading the way for Honda LCR on numerous occasions - including from the 29th to 51st minute - but was pushed down to sixth in the end-of-session reshuffle.

Factory Ducati rider Hayden also had reason to feel hard done by, after being a pole contender throughout the hour, but dropping to seventh when the final laps had been registered.

The American will be joined on row three by Crutchlow's team-mate Andrea Dovizioso and the second factory Desmosedici of Valentino Rossi, who was one of the few manufacturer riders not to occupy pole at some point this afternoon.

Rossi was 1.4s from Stoner's pole time and 0.683s ahead of the leading CRT rider Aleix Espargaro (Aspar ART).

Alvaro Bautista, who will start from the back of the grid on Sunday after being penalised for his Assen collision with Lorenzo, could be forgiven for a cautious eleventh.

Pramac's Hector Barbera was among those caught out by the standing water, suffering a heavy fall on his way to twelfth place, with Colin Edwards rising from last at the midway point to 13th by the flag for Forward Racing.

Cardion AB Ducati's Karel Abraham, who missed the British MotoGP weekend and then withdrew from race day at Assen due to left hand injuries sustained in testing at Aragon, has been replaced by Ducati test rider Franco Battaini this weekend.

39-year-old Battaini, a veteran of the former 250cc class who also spent one season in MotoGP with WCM in 2005, qualified in 21st and last place.

Lorenzo has won four races this year and Stoner the other three.

Qualifying:

1. Casey Stoner
2. Ben Spies
3. Dani Pedrosa
4. Cal Crutchlow
5. Jorge Lorenzo
6. Stefan Bradl
7. Nicky Hayden
8. Andrea Dovizioso
9. Valentino Rossi
10. Aleix Espargaro
11. Alvaro Bautista
12. Hector Barbera
13. Colin Edwards
14. Randy De Puniet
15. Mattia Pasini
16. Danilo Petrucci
17. Michele Pirro
18. Yonny Hernandez
19. Ivan Silva
20. James Ellison
21. Franco Battaini