Germany reached the quarter-finals of the World Cup but were taken to extra-time by Algeria in Porto Alegre.
Andre Schurrle finally broke the deadlock in the 92nd minute.
Mehdi Mostefa then spurned a good chance to level for the Desert Foxes.
Mesut Ozil scored in the final minute of extra-time to double Germany's lead.
However there was still time for Abdelmoumene Djabou to pull one back as Germany ran out 2-1 winners and set up a meeting with France on Friday.
The 90 minutes were goalless, but the match was not short of incidents.
The Africans dominated the opening 20 minutes with Manuel Neuer coming off his line to deny Islam Slimani.
Sofiane Feghouli then worked an opening but failed to deliver a final ball.
Slimani had a goal ruled out for offside.
Before Faouzi Ghoulam fired just wide.
Mostefa also saw a shot deflected just past the post.
Germany's best chance of the first half was foiled by this double save from Rais M'Bolhi.
Die Mannschaft had a fast start after the break and Shkodran Mustafi could have done better with this header.
Captain Philipp Lahm also tested the 'keeper.
However, Algeria continued to cause danger and Feghouli went close once more.
Then Slimani warmed the hands of Neuer.
In the final 15 minutes, Thomas Muller's header was turned away by M'Bolhi.
Then the Bayern Munich forward failed to hit the target after carving out a good chance.
The last chance of the 90 minutes fell to Bastian Schweinsteiger, but his header was straight at the 'keeper.
Like the new article format? Send us feedback!