Marko Pantelic missed a glorious late chance to send Serbia into the round of 16 as Ghana went through on goal difference.
Pantelic fired over in injury time moments after hauling Serbia back into their final Group D game against Australia in Nelspruit.
Ultimately Serbia paid for their earlier profligacy as second-half goals from Tim Cahill and Brett Holman sent them crashing out.
Australia's effort dragged them off the bottom of the group but it was too little too late as Ghana edged them out of the last 16 on goal difference.
It was a face-saving win for Australia that seemed barely likely in the first half as they struggled to cope with Serbia's pace and technical excellence.
Serbia had the first opportunity when Milos Krasic, booed by Australia's sizeable following after a tumble in the box moments earlier, burst into the box and fired at Mark Schwarzer from a tight angle.
Krasic had another chance after 11 minutes as Serbia broke quickly following an Australia corner.
Milos Ninkovic played him through with a superb pass but the CSKA Moscow star shot high and wide after rounding the advancing Schwarzer.
Serbia maintained the pressure and went close again when Zdravko Kuzmanovic shot across the face of goal.
Australia were struggling to handle the speed of the Serbian attacks and were grateful when Schwarzer stuck out an arm to deny Chelsea's Branislav Ivanovic from inside the six-yard box.
Australia were limited to firing in crosses from deep but it was 32 minutes before Serbia failed to deal with one and Cahill headed his side's first good chance wide.
Australia were almost caught out by another slick Serbia move before the break but Krasic was marginally offside before flicking the ball past Schwarzer.
Australia began the second period with more purpose and won a free-kick after Cahill tangled with Nemanja Vidic.
Marco Bresciano drilled the set-piece in low but Nikola Zigic was back to clear.
Cahill also sliced a shot wide from a Josh Kennedy flick-on but the Socceroos remained vulnerable on the counter-attack.
Milan Jovanovic broke clear on the left and Zigic controlled his cross brilliantly only to shoot over.
Australia, again showing more intent, went close as Jason Culina drilled a low shot wide.
Bresciano then forced Vladimir Stojkovic to make his first serious save from a low free-kick after Ninkovic was booked for a late tackle on Luke Wilkshire.
Kuzmanovic headed a good chance wide for Serbia but the eastern Europeans were starting to look concerned.
They paid the price for their earlier profligacy as Wilkshire picked out Cahill with a superb cross in the 69th minute and the Everton star headed powerfully home in familiar fashion.
Serbia were rattled and Australia began to sense an unlikely opportunity as substitute Holman broke forward four minutes later and unleashed a ferocious shot that flew past Stojkovic from 30 yards.
Serbia grabbed a lifeline six minutes from time as Schwarzer spilled a long-range Zoran Tosic shot and fellow substitute Pantelic pounced from close range.
That allowed them to regain their composure and they created one last gilt-edged chance but Pantelic was unable to convert.