Germany set up a World Cup last-16 contest with England as Mesut Ozil's stunning strike proved enough to earn victory over Ghana, who also qualified from Group D.
Ozil settled an entertaining affair in the second half with a wonderful, dipping volley from outside the box to ensure it would be the Germans who face Fabio Capello's men in Bloemfontein on Sunday.
In a game that swung from end-to-end, at breakneck speed at times, Ghana wasted some fine chances, but the African side go through as group runners-up, thanks to Australia's surprise victory over Serbia, and they will now face USA in Rustenburg on Saturday.
Going into the game Ghana only needed a point to be sure of progressing, but they came up against a German team desperate to put their shock 1-0 defeat at the hands of Serbia in their last match behind them.
Knowing a win would set up a clash with old rivals England, Germany played with great tempo and after Cacau shot at Richard Kingson, Lucas Podolski went close with a deflected volley that flew narrowly wide of the target.
But Ghana weathered the early storm and eventually asserted their own style on proceedings. They were content to let Germany have a lot of the ball and hit them on the break when they won it back and their pace soon began to cause problems.
Asamoah Gyan should have done better with a shot that was superbly blocked by the tireless Bastain Schweinsteiger before Kevin-Prince Boateng played in Gyan, only for the striker's touch to let him down at the crucial moment.
After Ozil rolled a tame shot at Kingson from the right-hand side of the Ghana box it was the Africans who twice went close again when Gyan's goal-bound header from a corner was cleared off the line by Philipp Lahm and then Boateng glanced across the face of goal from Andre Ayew's centre.
Germany knew raced out of the blocks after the interval, aware that Serbia and Australia were goalless at the break and a Serbia goal could send Germany out.
After Asamoah spurned a rare Ghana break into the Germany half by shooting at Manuel Neuer, Ozil produced his match-winning moment.
The gifted playmaker had endured a frustrating evening up to that point, but when the ball fell to him just outside the penalty area, he set himself up and then crashed a glorious left-footed effort past Kingson's fruitless dive.
Now Ghana had most to lose and they tried to hit back immediately as Prince Tagoe's goalbound header at the far post drew a superb block from Jerome Boateng - the German defender who was playing against his brother, Kevin, in a first for the World Cup.
Ghana continued to press and Gyan's backheel exquisitely set up Ayew only for Lahm to get in a last-ditch goal-saving challenge, and Germany eased through the closing stages without looking unduly troubled.
Even after the final whistle blew, there were some nervous moments for Ghana as they waited for the result from Nelspruit, but in the end they had done enough to secure Africa's first place in the next round.
Attempts on target
Attempts off target
Projected table based on current scores
|Group A teams||P||W||D||L||F||A||GD||PTS|
|Group B teams||P||W||D||L||F||A||GD||PTS|
|Group C teams||P||W||D||L||F||A||GD||PTS|
|Group D teams||P||W||D||L||F||A||GD||PTS|
|Group E teams||P||W||D||L||F||A||GD||PTS|
|Group F teams||P||W||D||L||F||A||GD||PTS|
|Group G teams||P||W||D||L||F||A||GD||PTS|