The Spaniard was joined on the front row by Red Bull's double world champion Sebastian Vettel, who will be attempting to win a Grand Prix in his native Germany for the first time.
Vettel's team mate Mark Webber, second in the championship after nine of the 20 races, was third fastest but the Australian will drop five places after being penalised for an unscheduled gearbox change before qualifying.
Seven-times world champion Michael Schumacher, fourth fastest for Mercedes in front of his home fans, will therefore start alongside Force India's Nico Hulkenberg on an all-German second row.
"It was not fun, that's for sure," said Alonso of his second pole in a row, with the other coming at a wet Silverstone two weeks ago, and 22nd of his career.
"When you have this type of conditions it's very difficult to put a clean lap together and very easy to finish in the gravel or in the grass or in the wall.
"It's a bit of a survival moment. You try to complete the lap and whatever the position is, you are happy," added the double world champion.
A huge clap of thunder shuddered over the circuit before the start of the second part of qualifying, announcing a deluge which left pools of standing water all over the track.
"In these conditions it's always a bit of a lottery," said Vettel, who has yet to win a race in July. "You can lose the car without making any mistake."
"I think we have shown the car is strong in all conditions," said Webber. "But it's never ideal to put ourselves on the back foot by shooting ourselves in the foot
McLaren pair Jenson Button and Lewis Hamilton, who have had a disappointing last two races, were seventh and eighth fastest after looking quick on Friday with new upgrades but will move up due to Webber's demotion.
Germany's Nico Rosberg, Schumacher's team mate, and French driver Romain Grosjean for Lotus also have five place penalties for Sunday's race due to gearbox changes.