Germany breathed new life into their World Cup defence after Toni Kroos' dramatic injury time winner secured a 2-1 comeback victory over Sweden in Sochi.
Knowing anything but victory would make it difficult for them to qualify from Group F, the defending champions found themselves behind after Ola Toivonen's 32nd-minute strike.
Germany were back on level terms immediately after the restart through Marco Reus (48) but three points were seemingly slipping away from Joachim Low's side, especially after Jerome Boateng was sent off in the 82nd minute after two bookable offences.
However, Kroos produced a moment of magic in the final minute of stoppage time to get Germany's World Cup defence back on track and break Swedish hearts.
Victory leaves Germany knowing a win over South Korea in their final group match will almost certainly see them progress with Sweden facing Mexico, who won earlier in the day.
Germany: Neuer (7), Kimmich (8), Rudiger (6), Boateng (4), Hector (7), Kroos (9), Rudy (6), Reus (7), Draxler (5), Muller (5), Werner (7).
Subs: Gundogan (7), Gomez (7), Brandt (6).
Sweden: Olsen (8), Lustig (7), Granqvist (7), Lindelof (7), Augustinsson (7), Claesson (8), Larsson (7), Ekdal (7), Forsberg (8), Berg (7), Toivonen (8).
Subs: Durmaz (5), Guidetti (6), Thelin (6).
Man of the match: Toni Kroos.
Germany started like a side with a point to prove following their 1-0 defeat to Mexico last weekend and they created an early opening as Timo Werner's cross picked out Reus, but the Borussia Dortmund forward's shot was blocked by Sebastian Larsson.
Low's side were dominating the ball in the early stages but just as against Mexico, they were given an early warning on the counter-attack as Marcus Berg raced away from Jerome Boateng, but the striker, who was seemingly pushed by the Bayern Munich defender, saw his shot saved by Manuel Neuer. Sweden were adamant they should have had a penalty but Polish referee Szymon Marciniak waved away the appeals and refused to consult VAR.
It was a warning Germany, who replaced the injured Sebastian Rudy with Ilkay Gundogan in the 30th minute, didn't heed as Sweden took the lead. Viktor Claesson's inch-perfect ball over the top picked out Toivonen, who brought the ball down on his chest before lifting it over a stranded Neuer.
Germany, who were now staring down the barrel of an early exit, almost hit back straight away but Robin Olsen pulled off a superb double save to keep out Gundogan's deflected shot and Thomas Muller's rebound.
Mesut Ozil dropped out of Germany’s starting line-up as coach Joachim Low made four changes to the side that lost 1-0 against Mexico in the opening game last weekend. Mats Hummels also missed out because of injury, while Sami Khedira and Marvin Plattenhardt were also left out. Marco Reus, Jonas Hector, Sebastian Rudy and Antonio Rudiger came into the team.
Sweden welcomed back Manchester United centre-back Victor Lindelof after he missed the 1-0 victory over the Koreans due to illness. He replaced Pontus Jansson.
However, it could have been even worse for Low and his side with Neuer needing to be at his best to keep out Berg's powerful header on the stroke of half-time.
With their World Cup hopes slipping away Mario Gomez replaced Julian Draxler at half-time and within 90 seconds Germany were level when Reus bundled Timo Werner's cross into the back of the net for his first international goal in more than three years.
Reus went close to a second, missing an attempted backheel by inches after being picked out on the six-yard box by Joshua Kimmich's cross.
Germany started to sense their opportunity, pinning Sweden back but a second yellow card for Boateng saw them play the last eight minutes with 10 men.
Olsen then produced a brilliant save to tip Gomez's header over the bar and substitute Julian Brandt's long-range strike crashed against the post, but Kross stepped up at the death to revive Germany's World Cup hopes.
- Germany came from behind at half-time to win a World Cup match for the first time since 1974 - which was also against Sweden (0-1 at HT, won 4-2).
- Toivonen failed to score in 23 Ligue 1 games for Toulouse in 2017-18, attempting 19 shots without success - he scored with his second shot at the 2018 World Cup.
- Mario Gomez assisted Reus' goal with his first touch of the match after coming on as a half-time substitute.
- This was the first match at a major international tournament (Euros and World Cups) that Mesut Ozil hadn't started for Germany since he made his debut in 2010, ending a run of 26 consecutive starts.
- Sweden have lost a World Cup group stage match for the first time since June 1990, when they lost to Costa Rica - this defeat ends a run of 10 group games unbeaten.
- This was the ninth consecutive occasion that Germany have followed a defeat at the World Cup with a victory.
- Sweden goalkeeper Olsen conceded his first goal in 548 minutes of action - before this match, he last conceded against the Netherlands in October 2017 and had kept five consecutive clean sheets.
- Boateng is the first player to be sent off at the World Cup for Germany since Miroslav Klose in 2010 against Serbia.
Man of the Match - Toni Kroos
There were plenty of heroes for Sweden and but for a late world-class strike, the accolade could have been going to one of Janne Andersson's players. However, with Germany's grip on the World Cup loosening, Kroos stepped and produced just when his side needed it.
In the second half, the Real Madrid midfielder was the heartbeat of his side's performance, dragging his team forward at every opportunity.
Then, right at the death, the 28-year-old, who has been involved in five goals in his last five World Cup games (three goals, two assists), produced a moment of sheer brilliance, scoring the latest goal by Germany in World Cup history (excluding extra-time) to keep his side's chances of back-to-back successes alive.
Next up for Germany is a clash against South Korea on Wednesday at 3pm. Meanwhile, Sweden will play Mexico at the same time as Group F draws to a close.