Rosberg, a German, will start on the pole for his home grand prix on Sunday after making a lap around the 2.842-mile (4.574-kilometer), 17-turn Hockenheimring circuit in 1 minute, 16.540 seconds. He claimed his fifth pole of the season and the ninth of his F1 career.
Two weeks ago, Rosberg started on the pole for the British Grand Prix but suffered his first retirement of the season due to a faulty gearbox. Since then, the 29-year-old Rosberg got married to his long-time girlfriend Vivian Sibold and signed a new multi-year contract extension with Mercedes. Germany won the 2014 FIFA World Cup Final as well.
Rosberg has finished no better than fourth in seven German GP starts. He placed ninth in this race last year.
Hamilton, who won his home grand prix in Great Britain and moved to within four points of Rosberg, wrecked during the mid-stages of Q1. He lost control and spun out before slamming hard into the barrier due to brake disc failure on his right-front.
Hamilton was not injured but complained of soreness after making impact at a high rate of speed. He was taken to the track's medical care center for observation and soon released. Hamilton finished 16th in qualifying but moved up one spot on the grid following a penalty for Sauber's Esteban Gutierrez (assessed for causing a collision during the British GP).
Valtteri Bottas from Williams qualified second, while his teammate, Felipe Massa, placed third.
McLaren's Kevin Magnussen took the fourth spot. Daniel Ricciardo from Red Bull was fifth, followed by his teammate, Sebastian Vettel, the four-time and defending F1 world champion as well as the winner of last year's German GP, which was held at the Nurburgring circuit.