Ivorian skipper Franck Kessié put his side ahead in the 30th minute at the Toronto Stadium.
And they kept the Germans at bay in a rugged, gritty contest until mid way through the second half.
Nadiem Amiri crossed the ball from the right wing and Undav ran in between Ivorian defenders to volley it into the net past the Cote d'Ivoire goalkeeper Yahia Fofana.
At 1-1 and the game in its closing stages,Cote d'Ivoire substitute Nicolas Pépé zoomed down the right wing and sent a pass over to the unmarked Simon Adingra on the left side of the penalty area.
Hesitant Adingra wastes late chance
But rather than trying a first time shot to beat the Germany goalkeeperManuel Neuer, the 24-year-old took a touch and the German defence cleared the danger.
The Monaco striker, who was judged the young player of the tournament as Cote d'Ivoire surged to the Africa Cup of Nations title in 2023, paid the price for his indecision a few minutes later.
Football history: Jules Rimet, the man behind the World Cup plan
Felix Nmecha picked up the ball in midfiled and rifled a pass to Undav who controlled it with his right foot and flashed a left-footed shot past Fofana.
The 29-year-old, who plays for the Bundesliga club Stuttgart, was mobbed by his teammates.
"Winning mentality, team spirit - we had exactly what you need to be successful in a tournament," Germany defender Jonathan Tah told German broadcaster MagentaTV.
Germany get chance to claim pool
"We never gave up, we kept going no matter what," added the 30-year-old.
"The guys coming off the bench brought energy. Deniz deserves a special mention, outstanding!"
Germany, with six points, will go into their final game in Group E against Ecuador on 25 June needing only a point to secure top place in the pool.
Cote d'Ivoire will advance to the knockout stages for the first time with a win over World Cup debutantsCuraçao.


Iran says closed Strait of Hormuz as US deal hits obstacle ahead of Swiss talks
World Cup 2026: Brobbey, Gakpo score braces as rampant Netherlands crush Sweden
'What power do you have to collapse NPP you did not build?' – Awal Mohammed jabs...
Chaos at Central University as vendors demand refunds after SRC Week cancellatio...
GMet issues severe weather alert for Northern Ghana as heavy rainstorm approache...
Ken Ofori-Atta is the first Ghanaian minister to use sickness to flee from accou...
Family demands justice for 14-year-old girl allegedly raped, killed in Binaba
Trump cuts HIV funding to South Africa
88 dilapidated buildings marked for demolition in Sekondi-Takoradi
Police crack suspected robbery network in Ashanti South, two suspects killed in ...