JOHANNESBURG (AP) — Germany won. Ghana lost, then won.
Mesut Oezil scored on a left-footed blast from outside the area Wednesday to give Germany a 1-0 victory over Ghana and first place in Group D at the World Cup.
Still, Ghana had reason to party.
Moments after the game was over, Ghana learned that Australia had defeated Serbia 2-1 — a result that meant Ghana took second place in the group and also will move on to the round of 16.
"It was a very difficult match, but we fought and it was enough to get us through," said Ghana midfielder Andre Ayew. "We had opportunities but the important thing is that we went through."
Once the scoreboard flashed the Aussie final, Ghana players hugged each other, waved their country's flag and ran to the corner where their supporters were cheering and dancing.
The Germans, too, were saluting their fans and enjoying the moment.
"It was a tense game. We could have made more out of our opportunities," Germany coach Joachim Loew said. "We were not very precise up front. But I can't blame my young players, there was a lot of pressure, we had to win."
The Germans had been heavily favored to take the group but an upset loss to Serbia left them needing a victory to be assured of advancing. They'll play England on Sunday, another European power that won to stay alive Wednesday.
Ghana will face the United States on Saturday. The Black Stars pushed the U.S. out of the tournament in 2006.
Ghana is the first of the six African teams in the tournament to make it to the knockout phase. It could also be the last. Only Ivory Coast still has a chance to join the Black Stars in the final 16.
Oezil had a chance to score in the 25th minute but Ghana goalie Richard Kingson blocked his shot. The German playmaker struck his winner in the 60th minute.
"I simply shot the ball," Oezil said. "I had a lot of support from my teammates. It doesn't matter whom we play next, we have to keep winning."
Ghana also had some chances and Kwadwo Asamoah broke through in the 51st minute but shot weakly at goalkeeper Manuel Neuer.
The game featured half brothers Kevin-Prince Boateng (Ghana) and Jerome Boateng (Germany) playing each other, though the two had little contact.
"There is no time to celebrate, the next match is very close," said Ghana's Serbian coach, Milan Rajevac. "We knew it would be a tough match because to try to qualify against Germany is really hard. We played quite well, we resisted well, we had some chances but they had to win and they showed that they are among the best teams in the world."