Max Kruse came off the bench to score the goal that sent Germany to Euro 2016 as Group D winners with a 2-1 victory over Georgia.
After wasting a host of early chances, the world champions were becoming frustrated in Leipzig after Jaba Kankava cancelled out a Thomas Muller penalty with a stunning strike.
Conceding another and slipping to defeat might have meant missing out on automatic qualification altogether but Kruse eased Germany nerves in the 79th minute, just moments after coming on.
Victory rendered the result of the clash between Poland and the Republic of Ireland academic as far as Germany were concerned and secured top spot.
That Joachim Low's men would need such a late goal seemed unlikely as they tore into the Georgians in the first half, doing everything but score.
Muller controlled on his chest and forced Nukri Revishvili into the first of several fine saves with a smart shot on the half-volley after just three minutes before Toni Kroos volleyed wide.
Revishvili denied Ilkay Gundogan and Marco Reus in quick succession before the latter blazed over from close range after good play by Mesut Ozil and Muller.
Amid Germany's succession of chances, Georgia had one of the best opportunities of the first period as Valeri Kazaishvili teed-up Tornike Okriashvili but Manuel Neuer produced a fine reaction stop.
Back at the other end, Reus was slipped in by Gundogan but screwed his shot across goal and then volleyed hard at Revishvili from an Ozil cross.
After 15 attempts on goal without joy in the first half, Germany finally looked to have taken control after Muller struck from the spot after 50 minutes.
Referee Pavel Kralovec had no hesitation in awarding the penalty after Ozil was tripped by Kankava and Muller made no mistake from 12 yards.
But Germany's joy was short-lived as Georgia broke upfield and Okriashvili brought a brilliant save from Neuer with a shot destined for the top corner.
The danger was not over as the resulting corner was cleared only as far as Kankava and the Georgia captain made amends for his earlier error by rifling in a superb left-foot volley.
Things almost got worse for Germany as a quick Georgia counter-attack led to a chance for Kazaishvili but he shot over before Neuer rescued his side after some poor defending with a brilliant save from Okriashvili.
Germany began to look laboured and Andre Schurrle, who had a frustrating night in a central role, shot straight at Revishvili after a good move.
Desperation appeared to be creeping in as Kroos missed the target by some distance from long range but the late introduction of Kruse for the ineffective Schurrle changed the game.
Kruse had been on the field just three minutes when he was fed on the edge of the box by an incisive pass from Ozil and he beat Revishvili with a firm first-time shot into the bottom corner.
Having regained the initiative, Germany duly played out time to book their place in France next summer.