Jamal Musiala scored his second goal of the tournament to help Germany beat Hungary 2-0 on Wednesday and book its spot in the European Championship knockout stage.
Musiala opened the scoring in the 22nd minute with a goal that was furiously protested by Hungary. Ilkay Gündogan had set that up and the Germany captain got on the scoresheet himself in the second half.
The 21-year-old Musiala had netted Germany's second goal in the 5-1 opening victory over Scotland on Friday. Hungary lost 3-1 to Switzerland on Saturday and now faces an uphill challenge to advance.
Hungary plays Scotland in the final Group A match on Sunday, when Julian Nagelsmann's team takes on Switzerland.
Germany is definitely into the next round at least as a best third-place team. It will be confirmed in the top two if Scotland fails to beat Switzerland later Wednesday.
Hungary was unbeaten in its previous three matches against Germany, winning the last time the two met, and it put up a good fight against the host nation in Stuttgart.
Marco Rossi's side started aggressively and stunned Germany by almost taking the lead inside 20 seconds. Goalkeeper Manuel Neuer had to be quick off his line to slide to the ball to stop Roland Sallai.
At the other end, Hungary goalkeeper Péter Gulácsi pulled off an impressive save to deny Kai Havertz.
The noise level ramped up every time Musiala had the ball and the Stuttgart-born forward opened the scoring in chaotic fashion.
Musiala tried to set up Gündogan but Hungary defender Willi Orbán got to the ball first. However, he stumbled — following what Turkey protested was a shove by Gündogan — and as Gulácsi tried to help him, Gündogan poked it on to Musiala, who smashed it into the net with the goalkeeper still on the ground.
Hungary almost leveled immediately but Neuer did brilliantly to parry Dominik Szoboszlai's free kick and then keep out a follow-up with his foot. The crowd celebrated the save almost as loudly as it had done the goal.
The loud home fans thought Musiala had doubled his tally at the end of the half but his shot was deflected, hitting the side netting and making it ripple so that even Nagelsmann appeared to think it had gone in.
Sallai had a header ruled out for offside in first-half stoppage time.
Germany was seemingly in control in the second half and Gulácsi denied first Gündogan and then Toni Kroos. But the host nation almost gifted Hungary an equalizer when shocking defending allowed Sallai to cross to Barnabas Varga for a free header from six yards out but it went narrowly over.
Germany doubled its lead in the 68th minute when Maximilian Mittelstädt rolled the ball across from the left and Gündogan drove it into the bottom right corner.