Oliver Neuville scored an injury-time winner as Jurgen Klinsmann's side virtually secured their place in the World Cup knockout stages by beating 10-man Poland 1-0 in Dortmund.
It looked as though Germany were going to be denied all three points in this Group A clash after Celtic goalkeeper Artur Boruc pulled off a string of magnificent saves.
But despite hitting the bar twice in the 90th minute - first through Neuville and then Michael Ballack - the hosts claimed their deserved victory when Neuville slid in to fire home a dramatic winner.
The hosts started brightly but it was Poland who had the first shot when Maciej Zurawski's 20-yard effort was easily saved by Jens Lehmann.
Germany almost broke the deadlock in the 21st minute when Philipp Lahm's cross picked out the lurking Miroslav Klose, but he somehow flicked his header just wide with the goal at his mercy.
In-form youngster Lahm then delivered another clever flick to the danger area in the 36th minute and Lukas Podolski controlled the ball well but could not steer the ball past Boruc.
And Lahm was once again the provider on the stroke of half-time when Podolski took the ball in his stride but somehow poked wide of the far post as he lost his balance with just Boruc to beat.
Germany made a bright start to the second half with Klose drawing a fine save from Boruc after Torsten Frings' free-kick had fallen to him in the area.
Poland were finding themselves more and more stretched and their bid to stay in the tournament was not helped when Radoslaw Sobolewski saw red for his second caution of the evening.
Boruc was then on hand to deny Lahm with a great save from close range, but with the danger not cleared he then denied Neuville from 10 yards.
Tim Borowski then blasted wide two minutes from time. But there was more drama to come as first Neuville with a header and then Ballack with a shot struck the underside of the crossbar, before David Odonkor fired the reound home only for the grounded Ballack to be flagged offside.
But Neuville ensured justice was done when he slid in to fire home Odonkor's cross with virtually the last kick of the game.