Germany scraped through to a World Cup quarterfinal meeting with France 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.
Schweinsteiger should have won the game in the final minute of normal time, but he fired a free header straight at the Algeria goalkeeper.
Moments earlier Muller fell over as part of a free-kick routine. Nothing was going right for the Germans.
That all changed less than two minutes into extra-time.
Muller pinched the ball off Algeria full-back Aissa Mandi and squared for Schurrle, who flicked the ball beyond M'Bolhi with his instep.
The Algerians tired, but they kept looking for the equaliser. Mostefa shot just wide when he should have tested Neuer.
Ozil scored in the final minute to give Germany a two-goal cushion, but Djabou then turned home Feghouli's cross to give Algeria a glimmer of hope.
There was not enough time for Algeria to find another though and Germany progressed.
