The German driver clocked a fastest lap of one minute 19.965 seconds on his final run after a slip-up by Fernando Alonso disrupted Hamilton's last charge on the drying Hungaroring track.
Torrential rain had delayed the start to qualifying and wrought havoc during Q1 which saw four red flags and Sauber's Marcus Ericsson, Williams' Felipe Massa and Manor's Rio Haryanto all crash.
Rosberg's final time was 0.143 seconds faster than Hamilton who had brushed aside earlier practice difficulties to ensure there will be a Mercedes one-two at the front of the grid Sunday.
"It was a really challenging qualifying. In the end it was pretty amazing that it dried out," Rosberg later told reporters. "I got a really good lap in on that last lap. Awesome. Very happy with that."
Hamilton, however, was left frustrated at his misfortune and what might have been.
"I felt good on my final lap and was four-tenths up," he said.
"It was unfortunate with Fernando but these things happen. We still have a long race ahead of us and I'll give everything from there."
Daniel Ricciardo and Max Verstappen, both of Red Bull, were third and fourth fastest respectively while Sebastian Vettel qualified fifth.
Toro Rosso's Carlos Sainz Jr. secured sixth place on the grid, while there was a positive performance for McLaren with Alonso claiming seventh and Jenson Button eighth position.
Nico Hulkenberg of Force India and Valtteri Bottas in the Williams closed out the top-10 positions.
Hamilton trails Rosberg by a solitary point in the drivers' championship ahead of Sunday's race but has performed well at the Hungaroring over the years.
The Briton has won there four times, a record only Michael Schumacher can match.
Hamilton has also been in fine form in recent weeks after notching victories at the Austrian and UK Grands Prix to close the gap on Rosberg.