Hamilton started only 14th after a mechanical failure in qualifying, but took the chequered flag at Hockenheim following a dramatic conclusion sparked by a rain shower, and Vettel's jaw-dropping crash.
Both Hamilton's Mercedes team-mate Valtteri Bottas and Ferrari's Kimi Raikkonen pitted for new tyres after the safety car was deployed following Vettel's costly accident.
Hamilton stayed on track to assume the lead, and when the race was back under way with 10 laps to run, the Englishman held off team-mate Bottas to seal a famous victory and afterwards thanked God for the win.
He said: "It is very difficult (to win) from that position and highly unlikely but you have always got to believe. I did a long prayer before the race and I wanted to stay collected and calm.
"I am so grateful. I kept pushing, kept believing and it happens. A big thanks to God. I hadn't thought about the championship. It was so tough out there. Conditions were perfect because when it rained, I knew that I would be in a good position."
More about: Hamilton