The 33-year-old's Mercedes suffered hydraulic failure in the first part of the session, grinding to a halt on the Hockenheimring track.
As a result, Hamilton will start the German GP from 14th on the grid as title rival Sebastian Vettel took pole position in front of a delighted home crowd.
The Briton had been fourth fastest at Hockenheim as he began his final run of Q1, but after running wide on Turn One and bouncing over the kerbs, the problems began.
Hamilton subsequently found himself unable to change gears and was ordered to stop out on the circuit because the problem risked damaging the engine.
Vettel, meanwhile, was faultless on his final run in and reclaimed pole position from Valtteri Bottas by 0.204 seconds, much to the delight of the fans in the grandstands.
Kimi Raikkonen was third quickest, with Red Bull's Max Verstappen fourth, while Haas drivers Kevin Magnussen and Romain Grosjean continued their team's recent strong form with fifth and sixth places on the grid.
German Grand Prix qualifying rankings
1. Sebastian Vettel (Ferrari)
2. Valtteri Bottas (Mercedes)
3. Kimi Raikkonen (Ferrari)
4. Max Verstappen (Red Bull)
5. Kevin Magnussen (Haas)
6. Romain Grosjean (Haas)
7. Nico Hulkenberg (Renault)
8. Carlos Sainz Jr (Renault)
9. Charles Leclerc (Sauber)
10. Sergio Perez (Force India)
11. Fernando Alonso (McLaren)
12. Sergey Sirotkin (Williams)
13. Marcus Ericsson (Sauber)
14. Lewis Hamilton (Mercedes)
15. Daniel Ricciardo (Red Bull)
16. Esteban Ocon (Force India)
17. Pierre Gasly (Toro Rosso)
18. Brendon Hartley (Toro Rosso)
19. Lance Stroll (Williams)
20. Stoffel Vandoorne (McLaren)