From a comically executed free kick to the slapstick folly of the defense, a laughably disorganized Germany struggled mightily against a determined Algeria.
Struggled, but still won.
The Germans beat a team many had underestimated 2-1 in extra time Monday to reach the World Cup quarterfinals for ninth straight time.
But it was only after Thomas Mueller fell to the ground during a free kick, and after the Algerians forced goalkeeper Manuel Neuer off his line and out of his area several times, that the Germans finally produced a stroke of brilliance early in extra time.
Andre Schuerrle backheeled in a goal in the 92nd minute, and then Mesut Ozil added another late in the match before the north Africans scored a consolation goal in the final seconds.
While it was Germany's first win in three matches against Algeria, the three-time champions will need more to overcome France in the quarterfinals.
There was little order and discipline in Germany's game in the cool conditions at the Estadio Beira-Rio. The team produced some chances but also gave away many more than it normally does and was lucky not to concede in a poor first half.
"We had major problems in the first half to organize the way we played," Germany coach Joachim Loew said. "Yes, we had our problems, but at the end we were better and had a lot of chances. The important thing is to advance."
The statistics would make Germany look fully in control: 78 percent possession, 16 shots on target for Germany against four for Algeria, a 22-7 edge on overall shots. But it was Neuer's unorthodox clearances that kept Germany in the match.
In other words, Germany was lucky.
With central defender Mats Hummels out with the flu, new man Shkodran Mustafi played as the right back and the reshuffled defense looked so unstable that every Algerian counterattack put it under pressure. Mustafi ended up tearing his left hamstring muscle late in the match and will miss the rest of the tournament.
But it wasn't just him. Normally reliable Per Mertesacker slipped while trying to clear a ball, allowing Algeria a big chance, and Jerome Boateng looked slow against the speedy Algerians.
Perhaps the most bizarre moment came in the 88th minute, with Germany about to take a free kick from a good position. Bastian Schweinsteiger ran past the ball, then Mueller slipped before running over the ball in an attempt to get behind the Algerian defense, and finally Toni Kroos tried to chip it over the wall. But his effort was low and the Algerians easily cleared what could have been a good opportunity.
The Germans have been working on set pieces, according to Loew, but that one surely needs some fine-tuning.
"You don't have to play fantastic every match," Loew said. "You have to win."