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'
|´Stupid´ Allardyce driven by money - Dyke|
|Wijnaldum vows to improve|
|Renato Sanches needs time at Bayern - Hitzfeld|
|Ibrahimovic nurturing United talent - Lingard|
|Mourinho feels sorry for Allardyce|
|United boss primed for ´must-win´ Europa League tie|
|Mourinho keen to protect under-fire Rooney|
|Jeonbuk Motors 4 Seoul 1: Leonardo brace puts hosts in the driving seat|
|Maloney returns to Scotland squad|
|Van Persie: Kids will decide my future|
|Entrapment won on this occasion - Allardyce|
|Ibra-Rashford pairing the answer for United - Neville|
|Tevez hints at imminent retirement|
|England in safe hands with Southgate - Glenn|
|Holman talks up A-League quality|
|CONCACAF Champions League Review: Red Bulls progress, Timbers win|
|Januzaj blow for Sunderland|
|Navas accepts blame for Dortmund equaliser|
|Sporting assistant Raul Jose pleased with win|
|Nuno left to regret slow start as Porto fail on English soil again|
|Vardy rejected Arsenal due to style|
|Simeone: I am not Griezmann´s mentor|
|Schmidt bemoans ´brutal´ Monaco equaliser|
|Ranieri doesn´t trust bookies over England job|
|Genesio worried wastefulness will cost Lyon in long run|
|Preud´homme admits Champions League too much for Club Brugge|
|Telegraph passes findings to FA after further corruption claims|
|Zidane: Draw difficult to accept|
|Pochettino delighted with in-form Son|
|Vietto undeterred by wasteful showing|
|Tuchel: Dortmund can still get better|
|Resilient Leicester display pleases Morgan|
|Glenn reflects on ´painful´ call to dismiss ´distraught´ Allardyce|
|Borussia Dortmund 2 Real Madrid 2: Late Schurrle strike salvages draw|
|Monaco 1 Bayer Leverkusen 1: Glik stunner snatches a point|
|Dinamo Zagreb 0 Juventus 4: Pjanic pilots comfortable victory|
|CSKA Moscow 0 Tottenham 1: In-form Son hits late winner|
|Copenhagen 4 Club Brugge 0: Delaney stunner helps Danish champions canter to victory|
|Sporting CP 2 Legia Warsaw 0: Magiera´s first game ends in defeat|
|Sevilla 1 Lyon 0: Ben Yedder seals win for Europa League holders|
|Leicester City 1 Porto 0: Slimani continues to haunt old foes|
|Shearer: Allardyce has made England a laughing stock|
|Howe, Pardew and Wenger among the contenders to succeed Allardyce|
|Emery´s PSG struggles give Ludogorets hope|
|Allardyce offers ´wholehearted apology´ for England shame|
|Lahm: ´Extraordinary´ Griezmann different to Lewandowski|
|Iniesta is the best in the world, claims Menotti|
|Irregular heartbeat ends Dempsey´s season|
|Bournemouth ´realistic´ over permanent deal for Wilshere|
|Guardiola warns against complacency|
|Allardyce and England part company after damning video|
|De Bruyne out for up to three weeks - Guardiola|
|Luis Enrique demands fast start at Gladbach|
|Ancelotti wary of Atletico threat|
|Al Ain 3 El Jaish 1: Caio capitalises on late error|
|Ter Stegen happy with solution to Bravo battle|
|Emery: PSG need time to gel|
|Hernandez: It was very difficult at Real Madrid|
|Derby stand down Pearson ahead of Cardiff match|
|Rodgers sympathises with ´poor guy´ Allardyce|
|Opponents are trying to get Ribery send off - Hoeness|
|Martino named Atlanta United head coach|
|Rodgers urges Celtic to have belief against City|
|Rodgers has made same impact as Guardiola - Brown|
|Benfica one of the best in Europe, warns Sarri|
|Menotti: Ronaldo never played in a team like Messi´s|
|Walcott happy to move on from Arsenal struggles|
|Champions League Matchday Two: Bayern hunt Atleti revenge|
|Coquelin facing three weeks out|
|Arsenal transfers beyond reproach, says Wenger|
|Schubert extends Gladbach contract|
|Lewandowski urges Bayern to learn from Atletico defeat|
|Griezmann feared Simeone to PSG was ´a done deal´|
|FA investigating Allardyce claims|
|Valencia keep Voro in charge for Atletico clash|
|One of Serie A´s all-time greats: The numbers behind Totti at 40|
|Toure brands FIFA ´complacent´ after racism taskforce closed|
|Emery expects Ronaldo to stay at Real Madrid|
|Tottenham not scared of Moscow trip - Alderweireld|
|Sessegnon signs with Montpellier|
|Rakitic delighted with form|
|Gameiro: I could have joined Barcelona|
|Stones talks up Celtic quality|
|Liverpool good enough to win title - Houllier|
|Klopp happy with Firmino in central role|
|Watford got bullied all over the pitch - Deeney|
|Nuno keen for Porto to end England misery|
|Legia boss Magiera set for whirlwind debut|
|´Terrific´ Burnley delight Dyche|
|Burnley 2 Watford 0: Landmark goals for Hendrick and Keane seal first win in four|
|Schmidt lauds hitman Hernandez|
|Klopp not banking on Liverpool winning title|
|Kroos plays down Ronaldo rage rumours|
|Confidence coursing through Copenhagen|
|Madrid form draws no concern for Zidane|
|Burki looking forward to ´dream´ Madrid clash|
|Juve and Higuain have work to do - Allegri|
|CSKA boss Slutski wary of Tottenham threat|
|Pochettino: Kane to return within three weeks|
|City youngster Diaz signs three-year deal|
|Aurier vows to ´continue working hard´ for PSG despite prison sentence|
|Tuchel expecting Ronaldo on top form|
|Ter Stegen eyes new Barcelona deal|
|Hazard: No excuse for Arsenal defeat|
|Cisse back in training with Auxerre|
|Hummels resumes training ahead of Atletico clash|
|Facing Barcelona´s MSN not a nightmare, insists Bravo|
|Thiago: Atletico defence best in the world|
|Alonso wants to end career at Bayern Munich|
|Ranieri went to Slimani for Porto advice|
|Draxler: Wolfsburg blocked my exit|
|Samoura defends abolishment of racism task force|
|Sampaoli backs Nasri for France recall|
|Gisdol ´twitching with joy´ at Hamburg presentation|
|Zanetti determined Inter will return to the top|
|Getafe sack Esnaider|
|Bartra happy with playing time at Dortmund|
|Aurier handed two-month prison sentence over police altercation|
|Klopp attributes Lallana´s fine form to hard work|
|Totti´s wife slams ´small man´ Spalletti|
|Guardiola has already done an amazing job at Manchester City - Alonso|
|Referees attacked by hooligans in Bosnia and Herzegovina|
|Griezmann: I am not the anti-Benzema|
|Sterling hails Guardiola´s role in goalscoring form|
|Champions League Matchday Two: Madrid look for first win in Dortmund|
|Smalling confident Rooney will bounce back|
|Vardy fears ´permanent stain against my name´ following casino incident|
|Brave Wilshere will reap rewards of loan move - Howe|
|MLS Review: Sounders surprise Galaxy, Kamara double sinks New England|
|Walcott a special case - Wenger|
|Guardiola striving for more after perfect 10|
|Chelsea risk another mid-table finish, admits Conte|
|Montella feels AC Milan lacked courage|