The two title rivals will line up together on the front row on Sunday, with Ferrari's four times champion Sebastian Vettel and Red Bull's Australian Daniel Ricciardo behind them on the second row.
The pole was Hamilton's ninth in 10 races this season and left him perfectly placed for a fifth career win at the Hungaroring. The Briton leads Rosberg by 17 points.
The 30-year-old was fastest in every session and looked untouchable on what must be one of his favourite tracks.
Grosjean to test Hamilton's 2019 Mercedes at French GP circuit
"I'm incredibly happy with the weekend," Hamilton told the BBC. "I can't remember having a performance as good as this."
A subdued Rosberg, however, couldn’t find a reason for his lack of speed. "I don't have an explanation," he said. "Qualifying went pretty much to plan, but I didn't find the pace. It has been a bit up and down all weekend for some reason. We need to look into it tonight.
"I am definitely not happy with how it went today."
McLaren were also upset after another poor showing. Fernando Alonso and Jenson Button will line up 15th and 16th on the grid after each of them had reliability problems.
Alonso made into the second session only for his car to break down on the first circuit.
The Spaniard jumped out and began pushing the car back to the pits. But when he arrived he was told he was unable to go out again.
"I was not allowed to compete again after the car doesn't arrive by itself into the garage, so when I knew the rules I thought: 'Why did I push so hard?'" he said.
FULL QUALIFYING RESULTS
Lewis Hamilton (Britain) Mercedes 1:22.020
2. Nico Rosberg (Germany) Mercedes 1:22.595
3. Sebastian Vettel (Germany) Ferrari 1:22.739
4. Daniel Ricciardo (Australia) RedBull - Renault 1:22.774
5. Kimi Raikkonen (Finland) Ferrari 1:23.020
6. Valtteri Bottas (Finland) Williams-Mercedes 1:23.222
7. Daniil Kvyat (Russia) RedBull - Renault 1:23.332
8. Felipe Massa (Brazil) Williams-Mercedes 1:23.537
9. Max Verstappen (Netherlands) Toro Rosso - Renault 1:23.679
10. Romain Grosjean (France) Lotus - Mercedes 1:24.181
11. Nico Huelkenberg (Germany) Force India - Mercedes 1:23.826
12. Carlos Sainz Jr (Spain) Toro Rosso - Renault 1:23.869
13. Sergio Perez (Mexico) Force India - Mercedes 1:24.461
14. Pastor Maldonado (Venezuela) Lotus - Mercedes 1:24.609
15. Fernando Alonso (Spain) McLaren
16. Jenson Button (Britain) McLaren 1:24.739
17. Marcus Ericsson (Sweden) Sauber - Ferrari 1:24.843
18. Felipe Nasr (Brazil) Sauber - Ferrari 1:24.997
19. Roberto Merhi (Spain) Marussia - Ferrari 1:27.416
20. Will Stevens (Britain) Marussia - Ferrari 1:27.949
1-10: third and final qualifying session 11-15: second qualifying session 16-20: first qualifying session
Portuguese Grand Prix
Race review: Hamilton and Mercedes flex mental muscles, Alonso shows promise
Portuguese Grand Prix
Hamilton fends off Red Bull challenge to win Portuguese GP