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.
Ufff respiran los alemanes. Que bien Feghouli. https://t.co/z6WvVlwOrC— Actual Fútbol (@actualfutbol) June 30, 2014
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.
El fallo de Muller http://t.co/VEaR9upwsq— noticias futbol (@noticias_futb0l) June 30, 2014
The last chance of the 90 minutes fell to Bastian Schweinsteiger, but his header was straight at the 'keeper.
Remate Schweinsteiger https://t.co/6QGTAJPuj4— Cesar Martinez Rojas (@cesar_martinezr) June 30, 2014