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.
More from FoxSports
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.
Gibraltar 0-6 Scotland
Steven Fletcher scored his second Group D hat-trick against Gibraltar as Scotland concluded their failed 2016 Euro qualification campaign with an easy 6-0 win over the section minnows at the Estadio Algarve in Faro.
Gordon Strachan's makeshift side - seven changes from the one which started in the 2-2 draw against Poland on Thursday night, which ended their hopes of reaching France next summer - took a two-goal lead into the interval after Chris Martin's first international goal was followed by a wonderful Shaun Maloney strike.
Fletcher, who scored three in the 6-1 win over Gibraltar at Hampden in March, netted twice in four minutes after the break and then grabbed another with a fine 85th-minute finish before Steven Naismith, on for Martin, made it 6-0 in added time.
The Scotland manager's contract is now up and he will reveal whether he will stay on in the post in the next week or so, but the Tartan Army inside the stadium certainly gave him their support during and after the game. A picture of the team and backroom staff taken on the pitch after the match.
Strachan, as promised, rang the changes.
From the starting XI against the Poles, only skipper Scott Brown, Alan Hutton, Matt Ritchie and Steven Fletcher survived.
Allan McGregor took over from David Marshall in goal, Gordon Greer and Christophe Berra came in as a center-back pairing with Derby forward Martin starting in attack.
There were also starts for Andrew Robertson, Graham Dorrans and Maloney.
Gibraltar, UEFA's newest member, had conceded 50 goals in nine previous losing qualifiers although their first competitive goal was scored by Lee Casciaro in the defeat at Hampden.
However, even a much-changed Scotland side were expected to win.