Germany scraped through to the quarter-finals of the World Cup despite being given a real scare by Algeria on a thrilling night of football in Porto Alegre.
Andre Schurrle and Mesut Ozil scored as Germany won 2-1 after extra-time, but for much of the night, it seemed Joachim Low's men were heading for what would have been the shock defeat of the tournament so far.
Algeria spotted Germany's vulnerable high-line defence from the first whistle and took advantage with a series of long-ball counter-attacks.
Germany goalkeeper Manuel Neuer played sweeper for much of the match in the Estadio Beira-Rio, racing out of his box to clear on four occasions.
Islam Slimani was a constant threat for the African nation, who looked like World Cup contenders, rather than knockout stage debutants.
Sofiane Feghouli and Faouzi Ghoulam were guilty of missing first-half chances for Algeria and Mehdi Mostefa also shot wide in extra-time.
Rais M'Bolhi had a superb game in the Algeria goal, saving from Philipp Lahm, Bastian Schweinsteiger and Schurrle in normal time.
But his efforts to avenge the 1982 'Disgrace of Gijon' - when West Germany and Austria conspired to eliminate Algeria from the World Cup - were ultimately ended by Ozil, who swept home in the second period of extra-time.
Abdelmoumene Djabou scored in the 120th minute, but Algeria could not find another as a massively relieved Germany sealed a quarter-final meeting with France in the Maracana.