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'
|Blatter not running for IOC re-election|
|Bendtner: Wolfsburg can challenge Bayern for Bundesliga honours|
|Liverpool relishing Britannia return, says Henderson|
|Everton big enough to keep Stones - Martinez|
|MLS Review: Fire stun Dallas as goals dry up|
|New Atletico signings excite Raul Garcia|
|Cahill expects Arsenal title challenge|
|Jovetic happy with Inter debut|
|Luis Enrique: Barca defence must improve|
|Yanev calls for calm after ugly scenes in friendly|
|Coppa Italia Review: Cittadella romp to victory, Brescia rely on penalties|
|Arsenal have learned how to play against big teams - Ramsey|
|Shawcross to visit specialist over back woe|
|Fiorentina 2 Barcelona 1: Bernardeschi double sends Barca to another defeat|
|Mancini hints at Melo interest|
|Rodgers hails ´incredible´ Benteke strike|
|Galatasary 1 Inter 0: Sneijder sinks former club|
|Wenger defends Arsenal approach|
|Wembley loss has no bearing on new season - Terry|
|Porto cruise to friendly win over Stoke|
|Mourinho denies Wenger ´snub´ suggestions|
|Arsenal abandoned their philosophy to win Community Shield - Mourinho|
|Mourinho throws Community Shield medal into Wembley crowd|
|Swindon Town 1 Liverpool 2: Benteke nets stunner on debut|
|Scottish Premiership Review: Hearts win thriller on top-flight return|
|Ujah at the double as Bremen beat West Ham|
|Mourinho: We were the better team|
|Wenger hails defensive solidity|
|Rooney returns as Villarreal spoil Ferguson´s party|
|Rodriguez stunner earns Southampton draw as Caulker makes debut|
|Arsenal 1 Chelsea 0: Case of 14th time lucky for Wenger against Mourinho|
|Taechaubol announces Milan agreement|
|Jojic fires Cologne to latest victory|
|China 0 South Korea 2: Kim and Lee seal victory|
|Origi getting up to speed|
|Costa a doubt for start of season - Mourinho|
|North Korea 2 Japan 1: Halilhodzic´s men spurn lead|
|Allam brands FA ´amateurs´ as name-change row rumbles on|
|Fournier ´worried´ by Lyon pre-season|
|Swansea still working on Michu exit - Monk|
|Neuer furious at Bayern Supercup defeat|
|Wenger: Ozil signing not a mistake|
|UEFA Champions League Preview: Shakhtar ready for Fenerbahce decider|
|Lampard targets MLS play-offs for City|
|MLS Review: Goals galore as DC United win 10-goal thriller|
|Ronaldinho returns and helps Fluminense to win|
|Keane: United won´t overtake Chelsea|
|Casillas has the ´enthusiasm of a 20-year-old´ - Lopetegui|
|Blanc hopeful over Ibrahimovic knee injury|
|Guardiola laments late goal in Supercup defeat|
|Tuchel plans to keep Bender|
|Hecking happy with Wolfsburg discipline after Supercup win|
|Arsenal players too interested in selfies and six-packs - Keane|
|Confusion over Ibrahimovic´s PSG future|
|Sporting Lisbon 2 Roma 0: Slimani, Mane inspire Portuguese hosts|
|Rodgers feeling ready for new campaign|
|Khedira to miss Supercoppa|
|Paris Saint-Germain 2 Lyon 0: Aurier and Cavani seal more silverware|
|Wolfsburg 1 Bayern Munich 1 (5-4 on penalties): Super-sub Bendtner nicks it for Pokal champions|
|Lampard´s long-awaited New York City debut ends in defeat|
|Casillas the spot-kick hero for Porto|
|Monk bullish ahead of season opener at champions|
|Marseille 2-0 Juventus: Night to forget for Serie A champions|
|Swansea end pre-season with yet another draw|
|HJK 0 Liverpool 2: Origi and Coutinho on target|
|Juventus rocked by Khedira injury scare|
|Lens and Pantilimon star as Sunderland beat Hannover|
|Pardew hopeful of concluding Wickham deal|
|Martinez allays Lukaku fears|
|Stuttgart 4 Manchester City 2: Cause for concern for Pellegrini|
|Wasteful Bournemouth held by Hoffenheim|
|Jerome seals Norwich win|
|Souare´s first goal ensures Palace draw|
|Sinclair hits hat-trick in Villa draw|
|Leicester end pre-season with thrilling Birmingham win|
|Wood and Mowatt condemn Everton to friendly defeat|
|Coloccini not involved as Newcastle lose to Gladbach|
|Borussia Dortmund 2 Real Betis 0: Ramos scores on return from injury|
|Stoke lose to Cologne on Afellay debut|
|Norwich capture goalkeeper Kean|
|Jovetic hits out at Pellegrini following City exit|
|Jones backing new boys to spark United revival|
|Scottish Premiership Review: Celtic up and running, Dundee hammer Kilmarnock|
|Can keen to learn from Milner|
|Immobile on the mend following friendly scare|
|Sagan Tosu 1 Atletico Madrid 1 (1-4 on penalties): Simeone´s men need spot-kicks|
|Cahill: Big-spending rivals will make title race tougher|
|Roberto happy to play full-back for Barca|
|Gestede eager to make his mark at Villa|
|I want to play more and score more - Remy|
|Lambert influence important, says Pulis|
|Benteke a ´bargain´ buy - Rodgers|
|Zola: Qatar would be ideal for Balotelli, Cassano|
|Suarez: I´m not among world´s best|
|PSG ready despite ´chaotic´ pre-season - Blanc|
|Arsenal thumping still hurts - Fournier|
|Aubameyang targets Champions League success|
|Rooney set for Everton return|
|Cech can match Van der Sar - Wenger|
|Mourinho ponders Wenger´s losing record against him|
|CBF confirm Fred failed a doping test|