A delightful goal from Andre Schuerrle and a counter-attack converted by Mesut Oezil carried a sloppy Germany into the World Cup quarter-finals Monday, 2-1 in extra-time against Algeria.
The opening goal of the Porto Alegre contest came two minutes into extra-time when Schuerrle directed a lovely backheel flick into the far corner. Oezil decided the tie in the 120th minute after Schuerrle's shot was cleared from the line.
Algeria managed a consolation through Abdelmoumene Djabou but could not stop Germany reaching the next round.
Germany meet France, who needed two late goals to dispatch Nigeria earlier Monday, in Rio de Janeiro on Friday in the quarter-final. Germany beat France in memorable semi-finals 1982 and 1986 after losing the first meeting for third place in 1958.
The game was a rematch of one of the World Cup upsets from Spain 1982 when Algeria secured a 2-1 group stage win over West Germany in Gijon. An earlier victory in a 1964 friendly put them in the rare position of holding a 100 per cent record over their opponents with two wins out of two.
That proud record came to an end despite a heroic effort against more illustrious opponents. It was a moment of true quality from Schuerrle, making the most of the slightest space on the edge of the six-yard box, which first separated the teams.
Germany never looked like losing the lead and substitute Christoph Kramer could have made things safe even before Oezil lashed home the eventual winner, capitalizing when Schuerrle was denied by a goalline clearance as he looked to complete a break away.
In the dying seconds Djabou converted a cross by Sofiane Feghouli at the back post but there was no chance to seriously threaten an equalizer.
Days after Algeria's famous win in 1982, the Germans played out a mutually-convenient 1-0 result with Austria in the final group match which ensured both European sides progressed while the North-Africans were eliminated.
On this occasion the Algerians could have no complaints of foul play; they were good, just not quite good enough.
Coach Vahid Halilhodzic made five changes from the starting eleven named in the final group game against Russia, and his side flooded forward on the break at every opportunity.
Feghouli and Faouzi Ghoulam shot off target early on from good positions either side of Islam Slimani having a spectacular header disallowed, correctly, for offside.
Throughout the game the Algerians attempted to exploit the intentionally high line held by the Germany back four which resulted in Manuel Neuer making several spectacular clearances as a sweeper.
Loew had to shuffle the starting 11 as Goetze replaced the injured Lukas Podolski, and Shkodran Mustafi came in at full-back as Jerome Boateng moved to central defence in place of flu-victim Mats Hummels.
Bastian Schweinsteiger was preferred to Sami Khedira alongside Philipp Lahm in defensive midfield and it was he who had Germany's first shot of the game after 12 minutes, forcing Adi Mbolhi to palm the ball high in the air.
This was a rare attempt by Germany in the first half though and it was only after the break that Joachim Loew's side began to pick up - even if they were still short of the form required to be contenders for the title.
Lahm had an effort tipped away, one of his final actions in midfield before moving to full-back for the injured Mustafi. The switch, which facilitated Khedira's introduction into midfield, certainly did not weaken the German team.
In a flurry of late pressure, Thomas Mueller had a powerful header saved and Schuerrle had his rebound attempt blocked, before Mueller poked wide after superbly controlling the ball in the box.
Algeria reached extra-time but were visibly tiring. Their resistance lasted only two minutes beyond the regulation 90 as Schuerrle broke the deadlock to the relief of the Germans.
There was late drama as Oezil and Djabou exchanged strikes in the 120th minute but Germany had done just enough to move on.