(CNN) -- Reigning world champion Casey Stoner emerged on pole at the end of a rain-hit qualifying session at the German MotoGP Saturday.
A downpour led to horrendous conditions for the riders at the Sachsenring and it was only on a drying track that the faster times were set.
Stoner on his Repsol Honda left it to the final moments to snatch first on the grid ahead Yamaha's Ben Spies and his own teammate Dani Pedrosa of Spain.
Britain's Cal Crutchlow continued the favorable impression he is making this season with fourth spot for the Monster Yamaha Tech 3 team, outqualifying Yamaha's joint-championship leader Jorge Lorenzo, who starts in fifth.
Local favorite Stefan Bradl put up a fine showing in front of his home fans to finish sixth fastest.
Stoner, who has said he will quit at the end of the season, is level on 140 points with Lorenzo at the top of the standings and has improved his title chances as he bids to add to his three wins this season.
He claimed his fourth pole of this year on a spare bike as conditions became more favorable.
"I was a little bit nervous going out there for the last 10 minutes because I didn't have the best set-up," he told the official MotoGP website.
"I am very happy because I didn't think we had done enough to be honest. I wasn't really happy with the way the bike was feeling in the turns but in the end we ended up with pole position."
The tricky conditions led to a number of crashes, with Hector Barbera the most notable casualty, although without serious injury.
Italian ace Valentino Rossi again struggled on his Ducati and was back in ninth spot, while San Carlo Honda Gresini's Alvaro Bautista will start from the back of the grid after being penalized for his crash last weekend at Assen where he took out Lorenzo on the first bend.