Hamilton finished ahead of his teammate Valtteri Bottas, who could only manage third place on a rare occasion when Mercedes failed to claim pole.
Jos Verstappen split the two drivers as he took second on the grid.
German Grand Prix
Disaster for Mercedes and Hamilton as Verstappen wins chaotic, wet German GP
28/07/2019 AT 11:48
"Lewis, this is Toto. You never stop to amaze us," team principal Toto Wolff, whose employers are also celebrating their 125th year in motorsport, told the Briton over the team radio.
Hamilton, winner of seven of the 10 races so far, leads Bottas by 39 points in the overall standings.
"I'm not really sure how we did it today, and I'm not really sure what happened to the Ferraris," said Hamilton.
"It's such an important race for us, our second home Grand Prix, and 125 years of motor racing, so it's incredible to celebrate in this way."
Vettel was unable to set a pace after a technical problem, meaning he starts at the back of the grid for Sunday's race.
Ferrari said the four-times Formula One world champion's car had suffered a turbo-related problem.
Vettel, who started last year's race on pole position but crashed out while leading, has not won a race since the Belgian Grand Prix last August.
The German reported a loss of power on the radio shortly after he left the pits for his first run during the opening phase of qualifying.
Additiona reporting from Reuters
German Grand Prix
Leclerc completes practice clean sweep for Ferrari in Germany
27/07/2019 AT 11:50
German Grand Prix
Leclerc keeps Ferrari on top of practice timesheets
26/07/2019 AT 16:53