Vettel looked certain to extend his lead at the top of the drivers' championship having opened up a nine-second lead at one stage, but he span off in drizzly conditions after 52 laps to blow the race - and the title picture - wide open.
Valtteri Bottas and Kimi Raikkonen both led in the wake of the crash, but Hamilton took advantage of their pit stops to move into the lead - a position he held for the final 10 laps after the end of the safety car to move back ahead of Vettel in the title race.
Bottas was ordered by Mercedes not to challenge Hamilton during the closing stages of the race as the Englishman sealed an unlikely victory, having started 14th on the grid after a hydraulics failure during qualifying yesterday.
In doing so, Hamilton became the first driver in 10 years to win an F1 race from 14th position or worse, and also the first driver since Nigel Mansell in 1992 to win back-to-back German Grands Prix.
Mercedes secured the one-two with Bottas finishing second, while Ferrari's Raikkonen completed the podium with a third-place finish.
1. Lewis Hamilton (Mercedes)
2. Valtteri Bottas (Mercedes)
3. Kimi Raikkonen (Ferrari)
4. Max Verstappen (Red Bull)
5. Nico Hulkenberg (Renault)
6. Romain Grosjean (Haas)
7. Sergio Perez (Force India)
8. Esteban Ocon (Force India)
9. Marcus Ericsson (Sauber)
10. Brendon Hartley (Toro Rosso)
11. Kevin Magnussen (Haas)
12. Carlos Sainz Jr (Renault)
13. Stoffel Vandoorne (McLaren)
14. Pierre Gasly (Toro Rosso)
15. Charles Leclerc (Sauber)