Germany’s injury time goal by Toni Kroos against Sweden revived the defending champions’ hopes of becoming the first side to retain the World Cup since Brazil in 1962.
Although Ola Toivonen’s deft first-half lob had left Joachim Low’s side facing elimination, Marco Reus, starting in place of Arsenal’s Mesut Ozil, prodded in an equaliser as Germany assumed control after the interval.
The champions then had Jerome Boateng sent off late on for a second yellow card but continued to chase the game knowing a draw left their fate in others’ hands.
And they were rewarded in the final minute of five added on when Kroos swept a free-kick into the top right corner from the left of the penalty area.
The result means all four teams in Group F can still qualify for the next phase, with the outcome to be decided at venues 600 miles apart on Wednesday 27 June (15:00 BST) when Mexico face Sweden in Ekaterinburg and Germany play South Korea in Kazan.