Germany were given a major scare before beating Algeria 2-1 on Monday to book a FIFA World Cup quarter-final meeting with France.
After a pulsating 90 minutes in Porto Alegre had ended goalless, Chelsea forward Andre Schurrle - on as a half-time substitute for Mario Gotze - cleverly flicked in Thomas Muller's low cross two minutes into extra-time to give Germany the lead.
Mesut Ozil added a second late on to wrap up victory for Joachim Low's side, before Algeria, who performed admirably throughout, gained a consolation through Abdelmoumene Djabou.
The result meant Algeria were unable to exact revenge for the "Disgrace of Gijon", when West Germany and Austria played out a mutually beneficial 1-0 scoreline that saw both sides through from the group at the expense of Algeria in the 1982 finals in Spain.
With many pointing to that infamous match as motivation for Vahid Halilhodzic's men in the build-up, Algeria flew out of the blocks in the opening 20 minutes, cutting through the German backline on a number of occasions and seeing an Islam Slimani goal disallowed for offside.
The African nation - making their first appearance in the second round - continued to impress, but Germany, who will now face France at the Maracana on Friday, finished the stronger and remain on course to reach the semi-finals of a fourth successive World Cup.
Algeria made a flying start and Manuel Neuer had to make a sliding tackle to deny Slimani an effort on goal from wide on the left in the ninth minute, after the goalkeeper had initially misjudged a charge from his line.
Sofiane Feghouli wasted a good position six minutes later, blazing the ball wildly across goal from the byline with two team-mates better placed.
Slimani converted Faouzi Ghoulam's wonderful cross from the left with a diving header in the 17th minute, but the referee's assistant correctly ruled that the Sporting Lisbon man had strayed offside, before Ghoulam flashed another effort narrowly off target as Algeria continued to dominate.
Germany gradually grew into the game towards the end of the first half, Muller heading wide and Ozil testing Rais M'Bolhi with a dipping effort.
Yet Algeria hit back in the 39th minute, Mehdi Mostefa thumping in a shot from 25 yards which deflected off Jerome Boateng and past the left-hand post with Neuer completely wrong-footed.
M'Bolhi made a superb double stop two minutes later, parrying Toni Kroos' drive away and then springing to his feet to keep out Gotze's rebound.
Germany enjoyed a more assured opening to the second period, Schurrle seeing an effort deflected just wide before Skhodran Mustafi, who replaced Mats Hummels (flu) in defence with Boateng switching to centre-back, headed straight at M'Bolhi from Kroos' delivery.
Philipp Lahm went close in the 55th minute, his curling effort diverted wide by an acrobatic save from M'Bolhi.
As the game wore on the play became stretched and Slimani sent a rasping effort from distance straight into the arms of Neuer 15 minutes from time.
Germany responded strongly and Muller ought to have scored his fifth goal of the tournament shortly afterwards, but his powerful header was beaten away by M'Bolhi.
Muller had another clear chance moments later, stabbing the ball wide after a glorious touch to bring the ball under control, while Bastian Schweinsteiger was unable to seriously trouble M'Bolhi with a weak header from Lahm's chipped pass.
Low's side then struck early in the first extra period, Schurrle adjusting brilliantly to backheel Muller's cross from the left into the net.
Algeria could have levelled through Mostefa, who snatched an effort wide from 10 yards after Germany failed to deal with a corner.
Ozil then made the game safe in the closing stages, lashing high into the net after Schurrle had been denied just in front of the goalline by Essaid Belkalem, although there was one final twist as Djabou converted a right-wing cross at the back post to net a deserved consolation for Algeria.
|Coach: J. Löw|
for M. Götze 46'
for S. Mustafi 70'
for B. Schweinsteiger 109'
|Stekelenburg grounded despite penalty heroics|
|Thiago Silva can be our Pirlo - Juve CEO hints at move for PSG defender|
|Koscielny calls for ´tough´ Arsenal|
|Birthday boy Wenger: Result will determine celebrations|
|MLS fines Drogba for Impact snub|
|Klopp backs Sturridge to bounce back|
|Conte: Chelsea still scarred from last season|
|Giggs: United decline was not inevitable|
|Falcao nets as brilliant Monaco hit Montpellier for six|
|Guardiola pleads patience for injury ravaged Kompany|
|No hard feelings as Mourinho focuses on Chelsea task|
|Guardiola: I don´t want City to play like Barcelona|
|Valencia fans´ Alcacer anger normal - Luis Enrique|
|Neymar: Playing for Barca is easy now|
|EPFL terminates agreement with UEFA|
|Aguero keeps Argentina spot, Messi returns|
|Donnarumma eyes Milan captaincy|
|Napoli fans banned from Juve trip|
|Mertesacker hails ´hungry´ hat-trick hero Ozil|
|Suarez says Barcelona renewal talks ´really advanced´|
|Lack of European football can aid Liverpool´s title bid - Pulis|
|European breaks do not benefit Chelsea - Conte|
|Pardew backs Leicester to ´come through´ tough start|
|Pochettino one of ´the very best´ coaches, says Howe|
|Puel backs Manchester City for Premier League title|
|Abramovich and I were not friends - Mourinho|
|It was not mutual consent, I was sacked by Chelsea - Mourinho|
|Brazil recall Douglas Costa, Marcelo and Casemiro for Argentina clash|
|Luis Enrique: If Messi is at his best, nobody knows how to stop him|
|Ramos deserves more than he earns - Perez|
|Neymar renewal proves Barcelona team spirit, says Luis Enrique|
|Bravo mistakes will be on the front page - Guardiola|
|I would sign Modric as Scholes´ successor - Giggs|
|At last! Neymar signs new Barcelona contract|
|Ronaldo injury helped Portugal to Euro 2016 success, says Abidal|
|Ronaldo injury helped Portugal to Euro 2016 success, says Abidal|
|Rummenigge blasts Premier League clubs for ´kidnapping´|
|Prandelli awed by Messi but ´dreaming big´ against Barcelona|
|Guardiola fumes at Aguero rumours after Barcelona omission|
|Conte: Mourinho deserves maximum respect|
|Moses happy for Conte chance after Mourinho struggle|
|Garcia dreaming of glory with lowly Marseille|
|Dawson back as Phelan expects Hull reaction|
|Conte declares Terry fit to face Mourinho´s United|
|Pardew: Why would I leave Palace for England?|
|Montella wants San Siro to strike fear into Juventus|
|Guardiola criticism ´political´, says Del Bosque|
|Ancelotti ready to unleash rampant Robben once more|
|Chelsea in a good position - Mourinho|
|Tuchel heartened by Reus return|
|Allegri wary of AC Milan after Inter ´whack´|
|Koeman hopes for Barkley ´wake-up call´|
|Melbourne City 2 Perth Glory 3: Keogh hat-tricks decider thriller|
|Dybala delighted to stay at Juve after rejected offer|
|Hughes eager to test Hull fragility|
|Carrasco extends Atletico contract|
|Moyes: I am under pressure - just like Guardiola|
|Wenger talks up Arsenal´s title credentials|
|Fuchs signs new Leicester contract|
|Guardiola doesn´t communicate - Benatia|
|Magical Messi from another planet, says awestruck Digne|
|Wenger pleased to see Ozil on goal trail as talks continue|
|Evra hails old rival Suarez as ´the best number 9´|
|Ranieri: I feel like a hybrid car|
|Falcao returns for Monaco|
|De Bruyne defends Guardiola tactics|
|Del Bosque: I rejected €10m offer from China|
|CONCACAF Champions League Review: Pumas, Dallas reach QFs|
|Alli like ´wild horse´ - Pochettino|
|Nani hails ´special´ Messi|
|Serious knee injury sidelines Hull´s Odubajo for six months|
|Mkhitaryan edging closer to comeback - Mourinho|
|Klopp: United game good prep for West Brom|
|Pogba praises Rooney after resounding win|
|Under-fire De Boer driven by reaching knockout stages|
|Pogba no longer Premier League´s ´worst´ player, mocks Mourinho|
|Austria Vienna spoil Totti milestone|
|Manchester United 4 Fenerbahce 1: Van Persie nets on return as Pogba stars|
|Puel rues unfortunate Inter defeat|
|Inter 1 Southampton 0: Candreva seals fortunate win for Inter|
|Buffon rules out club management after retirement|
|Mazzarri ´very happy´ about Holebas-Capoue row|
|Non-European city could host Champions League final - UEFA|
|Bradley calls for players to reconnect with fans|
|Pochettino lauds ´fantastic´ Howe|
|Frankfurt´s Russ eyeing return after tumour disease all-clear|
|Karanka insists Middlesbrough will not sit back against Arsenal|
|Atletico Madrid cannot sign players in January after FIFA deal|
|Koeman calls for greater Lukaku support|
|Suarez: Two goals at the Bernabeu were my best|
|Pochettino delivers mixed news on injury front|
|Karius has Klopp´s confidence|
|Suarez hopes to finish his career at Barcelona|
|Burnley suffer Defour injury blow|
|Marseille confirm Garcia appointment|
|No concerns for Ranieri as Vardy, Morgan and King miss training|
|Tony Pulis is Tony Pulis - Klopp not expecting surprises from West Brom|
|Garcia´s Roma contract terminated amid Marseille reports|
|Injured Pique ruled out for three weeks|
|Moyes the builder will fix Sunderland, says chief exec Bain|
|Walcott impressed by the ´new, aggressive´ Ozil|
|Bilic eyes Ayew injury boost|
|Bonaventura on Icardi saga: I´ll wait until I´ve won something before writing a book!|
|Van Persie: I may still be at Man Utd if Ferguson was in charge|
|Emery wants more from PSG despite victory|
|Muller: Bayern enjoyed PSV rout|
|Barcelona lose Alba and Pique to injury|
|Nolito: Messi made the difference|
|CONCACAF Champions League Review: Pachuca edge through, Timbers out|
|Ozil has ´taste´ for goals - Wenger|
|Renard, Morocco prepared for AFCON test|
|Guardiola: Barca loss not my worst|
|Luis Enrique hails ´decisive´ Messi|
|Pulisic, Green & Morris´ youth movement delight USMNT legend Jones|
|Clinical Barca point the way for Sterling and City|
|Sarri: Napoli making life hard for ourselves|
|That´s life for goalkeepers - Ter Stegen on Bravo woe|
|Schubert delighted with mature Gladbach display|
|Gunes not getting carried away after Besiktas upset Napoli|
|Lucas praises PSG response to stuttering start|
|Luis Enrique happy to rule in game of errors|
|Vitoria: Benfica face three more finals|