Germany's win was not enough to keep them in the tournament after Japan caused an upset by beating Spain.
Germany's World Cup dreams were dashed on Thursday after the team was eliminated from the tournament, despite a 4-2 win over Costa Rica in their last Group E match.
The four-time champions had arrived in Qatar determined to restore their tarnished reputation following their shock group stage exit in 2018.
They instead finished third in the standings, level on four points with Spain but behind on goal difference, and will once again face an early return home.
Japan topped Group E with six points after beating Spain 2-1 and will face Croatia in the last 16, while Spain will take on Morocco. Costa Rica came in last place with three points.
During Germany's final match, the country had started off with a goal from Serge Gnabry in the 10th minute but saw the Central Americans score twice with Yeltsin Tejeda and an own goal by German goalkeeper Manuel Neuer (initially attributed to Costa Rica's Juan Pablo Vargas).
A Kai Havertz brace put Germany back in front, and fellow substitute Niclas Füllkrug added a fourth in stoppage time, but even that was not enough to prolong the team's World Cup stay.
It was the first time in the country's World Cup history that it failed to win any of their first two group matches. Despite their final victory, the Germans will leave Qatar with dropped heads.
"There are so many reasons but I am not looking for excuses," said Germany coach Hansi Flick.
"[T]he tournament was not decided today for us. We did not have any efficiency at this tournament and that is why we were eliminated."