Germany survived a huge test of their World Cup title credentials to see off underdogs Algeria in extra time and set up a quarter-final meeting with France.
The three-time champions lacked urgency throughout the 90 minutes and frequently looked rattled as an enterprising Algeria wasted a succession of chances before Andre Schurrle finished from close range early in the first additional period.
Mesut Ozil drilled in to double their lead and although Abdelmoumene Djabou volleyed home to ensure a frantic end, Germany held on and will take on the French in Rio on Friday.
The result looked inevitable once a hugely impressive Algeria side began to tire, but Joachim Low's men will have to improve dramatically if they are to secure a first World Cup since 1990.
Germany are into the last eight for the 17th time in 18 World Cup appearances, but they lacked the fluency and cutting edge that has seen them installed among the tournament favourites.
Algeria could not mark their first experience of the knockout stage with a win, meaning Africa's representation in Brazil is over, but they depart with immense credit for a superb campaign.
The build-up was dominated by talk of them seeking revenge for 1982, when West Germany's convenient 1-0 win against Austria saw them both reach the second round at Algeria's expense.
They beat the Germans in the group stage that year and looked determined to produce a repeat.
With a 5-1-3-2 formation and five changes to their starting line-up that saw playmaker Yacine Brahimi drop to the bench, the Desert Foxes appeared to be set up defensively.
But after an early spell of German pressure, they went in search of a shock lead and almost found it. Manuel Neuer made a vital challenge on Islam Slimani after Faouzi Ghoulam's ball up the left wing eluded Per Mertesacker, and it subsequently took an important tackle from the Arsenal centre-half to deny the same man.
Sofiane Feghouli then sliced through the Germany back line only to miscue his cross from a brilliant position, Slimani's diving header was correctly disallowed for offside and Ghoulam steamed through on the left but lashed his finish across goal and wide.
Germany eventually managed to exert an influence - Ozil's misdirected cross was tipped over the bar, Muller headed wide and keeper Rais Mbolhi spilled an Ozil drive - but Algeria refused to sit back and Mehdi Mostefa was the latest to come close with a strike that was deflected wide.
Mbolhi made a magnificent double save from Toni Kroos and Mario Gotze as Germany finished the half well, but it was no surprise when Gotze was replaced by Schurrle at the break.
The big question was whether Algeria would maintain their intensity or be punished for their missed chances and the answer nearly arrived when Schurrle's effort was deflected narrowly off target, before Shkodran Mustafi headed at Mbolhi and the goalkeeper pulled off a fine save from Philipp Lahm's shot.
Algeria responded by tightening up at the back and attempting to pounce on the counter-attack. Keeper Manuel Neuer was forced to operate as an auxiliary sweeper as Slimani escaped the German centre-backs, while Feghouli drilled wide and then Slimani lashed powerfully at Neuer.
At the other end, Mbolhi made another stunning stop from Muller's header while Esseid Belkalem and Ghoulam cleared off the line from Schurrle and Benedikt Hoewedes respectively.
Algeria were visibly tiring and after Muller and Bastian Schweinsteiger threatened a winner late in the 90 minutes, Schurrle finally broke the deadlock in the opening moments of extra time.
Muller crossed low from the left for the Chelsea forward to dispatch with an improvised finish. It was the 14th of Germany's last 24 World Cup goals that Muller has been involved it.
Ozil rammed in a second before substitute Djabou converted from Feghouli's cross, but there was no time to find another goal as Germany celebrated and Algeria made a tearful exit.