An electrical issue meant Rosberg had to abandon his first run, and therefore headed out for one single three-lap stint three minutes from the finish. At that point Hamilton was provisionally fastest, but with the pressure on Rosberg vaulted his team mate to claim top spot.
Hamilton had time to respond, and was even up in the first sector - but he couldn't quite deny Rosberg a second straight pole on home turf.
Red Bull proved Mercedes' closest challengers, edging Ferrari to lock out the second row of the grid. Daniel Ricciardo labelled the lap that earned him third - just one tenth ahead of Max Verstappen - as a 'beauty'.
Ferrari were therefore confined to the third row, Kimi Raikkonen this time getting the better of home favourite Sebastian Vettel, while Force India and Williams rounded out the top ten through Nico Hulkenberg, Valtteri Bottas, Sergio Perez and Felipe Massa respectively - the quartet incredibly split by just 0.1s.
Esteban Gutierrez was unlucky to miss out on a Q3 berth, the Haas man winding up 11th ahead of McLaren's Jenson Button. The Briton's team mate Fernando Alonso was 14th, giving him a share of row seven with compatriot and Toro Rosso driver Carlos Sainz.
The latter's team mate Daniil Kvyat was the biggest surprise casualty in Q1, exiting alongside both Saubers, both Manors, and the Renault of Kevin Magnussen.
Mercedes fired an ominous warning to the rest of the field in that session, as they opted to run on the soft tyre - the rest of the field were on supersofts - and still wound up fastest, with Hamilton marginally ahead of Rosberg, Ricciardo and Raikkonen.
It looked as if Manor had got through to Q2 right up until the dying moments, but good laps for Button, Sainz and Renault's Jolyon Palmer left Pascal Wehrlein - who had been 13th fastest after the opening runs - eliminated in 18th. Kevin Magnussen in the second Renault was just 0.001s ahead in 17th, but was also eliminated, with team mate Palmer scraping into Q2 by just 0.080s.
Kvyat, Rio Haryanto in the second Manor, and the Saubers of Felipe Nasr and Marcus Ericsson, completed the bottom six in Q1.
Both Mercedes switched to supersofts for Q2, and Hamilton again headed Rosberg, 1m 14.748s to 1m 14.839s. This time Verstappen got closest, on the same rubber, with 1m 15.124s, followed by Raikkonen, Bottas, Perez and Ricciardo.
Further down, Vettel and Massa just made it through to Q3, leaving an impressive Gutierrez a disappointed 11th on 1m 15.883s for Haas ahead of Button, Sainz and Alonso. Romain Grosjean - whose gearbox was changed ahead of qualifying - was 15th for Haas on 1m 16.086s, with Palmer 16th on 1m 16.665s.
Sainz was later deemed to have impeded Massa unfairly however, earning the Spaniard a grid penalty for Sunday's race. Grosjean and Hulkenberg were also issued with grid drops, for separate technical infringements.
Q3 then opened with the electrical worry for Rosberg, and there was further concern for Mercedes as a fabulous run by Ricciardo saw him book a provisional front row slot alongside Hamilton.
On his first pukka run Rosberg got the job done beautifully, however. Smooth and fast and at his very best, the German stopped the clocks in 1m 14.363s. Hamilton’s reply was a little untidy, and though he improved slightly to 1m 14.470s it wasn’t enough.
Ricciardo also failed to improve but stayed third as Verstappen improved to 1m 14.834s, leaving the Ferraris breathless. Raikkonen stayed ahead of the troubled Vettel, with 1m 15.142s to 1m 15.315s.
With the various grid penalties counted for, the grid is set to line up thus: Rosberg, Hamilton; Ricciardo, Verstappen; Raikkonen, Vettel; Bottas, Hulkenberg; Perez, Massa; Gutierrez, Button; Alonso, Palmer; Sainz, Magnussen; Wehrlein, Kvyat; Haryanto, Grosjean; Nasr, Ericsson.
WATCH: Ride onboard as Rosberg claims dramatic pole on home soil at Hockenheim
Unfortunately, we are unable to play the video at this time.
Error Code: UNKNOWN