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'
|Terry calls for new Drogba deal|
|Saul agrees bumper Atletico deal|
|Arsenal need to finish season strongly - Wenger|
|New Bilbao deal for Gurpegi|
|Terry: Too long between titles|
|Pepe puts Morata friendship aside for Champions League match-up|
|Hazard can be as good as Messi, Ronaldo - Fabregas|
|Carlisle ´deeply ashamed´ about suicide attempt|
|Tevez planning to win Champions League with Juve|
|Blatter ´knows absolutely nothing´ - Maradona|
|Allegri: Ancelotti a smart man|
|Sunderland academy coach to manage Oldham|
|Primeira Liga Review: Braga secure Europa League berth|
|Bruce backing Hull to respond against Burnley|
|Almeria 2 Celta Vigo 2: Bifouma, Zongo inspire hosts´ comeback|
|Arsenal can mount title bid - Wenger|
|Turkish Super Lig Review: Besiktas and Galatasaray remain locked at the top|
|Cagliari 4 Parma 0: Festa revival back in gear|
|Hull City 1 Arsenal 3: Sanchez at the double as visitors close on second|
|Blackpool - Huddersfield game will not be finished|
|Allegri vindicated by Juventus success|
|Russian Premier League Review: Krasnodar close the gap as Zenit slip up|
|Al Ahly dismiss Garrido|
|MLS Preview: Kinnear returns to Dynamo with Earthquakes|
|Ancelotti all out for victory against Juventus|
|Ramires recovering well after sickness|
|Prince Ali would back rival FIFA candidate to oust Blatter|
|Barcelona v Bayern Munich: Guardiola makes Camp Nou return|
|Kruse a target for Wolfsburg - Allofs|
|Fletcher backing Bournemouth to ´surprise a few´|
|Bremen agree deal with Fritz|
|Carver gets Newcastle backing|
|Blaszczykowski suffers groin tear|
|Boateng warns of Barca ´storm´|
|Brouwers agrees Gladbach extension|
|Benzema to miss Turin trip|
|England great Jimmy Greaves suffers stroke|
|Cabaye concerned by bit-part role at PSG|
|Parry: Anfield expansion a major boost|
|Ki targets Arsenal win and seventh spot|
|Pirlo eyes potential Champions League swansong|
|Mourinho rounds on critics after clinching title|
|Henderson: Liverpool can push on without Gerrard|
|Lack of goals a concern for Van Gaal|
|Hard to keep Benteke - Bacuna|
|MLS Review: Sporting KC end Chicago streak, Martins brace furthers NYC pain|
|Copa Libertadores Preview: River eye revenge in Superclasico|
|Garcia lauds ´impressive´ Roma|
|Pavon goal scores him a BMW for a month|
|Boca beat River in Superclasico|
|Inzaghi to blood youth after third straight Milan defeat|
|Blanc urges PSG to ´remain vigilant´|
|La Liga Review: Valencia go clear of Sevilla, crisis-stricken Elche safe|
|CAF Champions League Review: ES Tunis dumped out by Al Merreikh|
|Masterful Mourinho has Premier League and Chelsea singing his tune|
|Nantes 0 Paris Saint-Germain 2: Cavani nets again as Ibrahimovic returns|
|Napoli 3 Milan 0: Late treble saves hosts|
|Primeira Liga Review: Porto edge past strugglers Vitoria|
|Bundesliga Review: Hamburg claim last-gasp winner, Gladbach close in on Wolfsburg|
|Pochettino: Hart heroics the difference|
|Ligue 1 Review: Monaco remain on course for third, Lille cruise past Lens|
|Pellegrini silent over City future|
|Rome derby not on Lazio´s radar, says Pioli|
|Pardew laments penalty calls in Palace´s loss to champions|
|Serie A Review: Roma move back into second, Di Natale overtakes Baggio|
|Tottenham 0 Manchester City 1: Aguero heaps more misery on Spurs|
|Mourinho appears to take dig at old nemesis Guardiola|
|Mancini frustrated by resilient Chievo|
|Drogba coy over future after title triumph|
|Chelsea title win will not lead to domination - Mourinho|
|Inter 0 Chievo 0: More frustration for Mancini|
|Terry: I´ve proved Benitez wrong|
|BREAKING NEWS: Chelsea secure Premier League title|
|Chelsea 1 Crystal Palace 0: Title heads back to Stamford Bridge|
|League One Review: MK Dons promoted, as Orient, Notts County and Crawley go down|
|Dortmund striker Ramos set to miss Copa America|
|Williamson denies getting sent off on purpose|
|Eintracht Frankfurt´s Kittel suffers injury blow|
|Juventus v Real Madrid: Serie A kings set for Real test|
|United still control top-four destiny - Young|
|Record finish beyond Stoke - Hughes|
|Wellington Phoenix 0 Melbourne City 2: Surprise win sets up semi-final derby|
|Vidal already focused on Real|
|MLS Review: Revs hand Red Bulls first loss|
|AFC Champions League Preview: Wanderers facing elimination|
|Lyon stepped up despite pressure - Fournier|
|Gerrard anticipating emotional Anfield finale|
|´I´ve always wanted to score a free-kick past Neuer´ - Calhanoglu|
|Negredo: Pellegrini lost faith in me|
|Buffon had title doubts after Conte departure|
|Luis Enrique: I was worried during 8-0 win|
|Wilshere will return to his best - Wenger|
|Rodgers unconcerned by banner|
|Mourinho doesn´t want guard of honour|
|Deportivo La Coruna 1 Villarreal 1: Hosts come from behind|
|Juve canter to title success as Allegri wins over doubters|