Germany set up a mouthwatering last-16 clash with England as Mesut Ozil's second-half strike proved the difference against Ghana at Soccer City.
The win for Joachim Low's side took them to the top of Group D and means they will face England in Bloemfontein on Sunday afternoon, while Ghana ensured African representation in the knockout phase by edging out Australia on goal difference. The Black Stars will now take on the United States in Rustenburg.
Germany created the first chance when Brazil-born Cacau, in for the suspended Miroslav Klose, broke through in the third minute but his low shot was easily gathered by Richard Kingson in the Ghana goal.
The German contingent were jeering any touch for Berlin-born Kevin-Prince Boateng, whose tackle on Michael Ballack in the FA Cup final last month ruled the Germany star out of the World Cup. However, the Portsmouth man was able to tune out from it and one incisive ball to Gyan should have led to a chance, but the Rennes forward's first touch was poor.
Kingson then had to react quickly at his near post as Anthony Annan deflected a Lukas Podolski cross from the left goalwards in the 10th minute, and at the other end a clever ball from Kwadwo Asamoah played in the advancing Boateng but Bastian Schweinsteiger did enough to cut out his cutback to Gyan.
The game was finely poised and Andre Ayew hesitated when a chance to shoot presented itself, and Ozil wasted a good opportunity for Germany when played in by Cacau as his shot was blocked by the legs of Kingson.
Gyan's glancing header from a corner was shepherded away from the goalline by Germany captain Philipp Lahm, although replays suggested he perhaps used his arm to initially keep it out.
Cacau was next to go close, hooking a shot on target after a clever flick from Sami Khedira which Kingson got down well to save.
Ghana were proving more than a match for the Germans and Boateng was just unable to get meaningful contact on an Ayew cross from the right.
Ayew was then unlucky to be booked for a challenge on Cacau and Schweinsteiger's resulting free-kick drifted all the way through to Kingson, who needed to push it away from danger.
Ghana created a golden opening early in the second period as Asamoah burst through, but his weak effort was blocked by the onrushing Manuel Neuer.
It was a costly miss as Thomas Muller found Ozil in space outside the area and he flashed a left-foot shot beyond Kingson on the hour mark to take Germany to the top of the group.
For the first time in the game Ghana had been slow to close down their opponents but their response was positive at least as Gyan header goalwards was blocked for a corner by Germany defender Jerome Boateng, the half-brother of Kevin-Prince.
Lahm made a crucial block to deny Ayew after Gyan back-heeled the ball into the path of the onrushing midfielder but Germany were not sitting on their lead and Cacau drilled a long-range shot goalwards which Kingson parried away awkwardly.
Ghana continued to press without creating too many clear-cut openings and Neuer was given a rare test by an Annan shot, although it appeared with Australia beating Serbia both teams were happy enough if the result stood and the last few minutes were played out uneventfully.