Australia ended their World Cup campaign with a 2-1 win over Serbia but both are heading home.
Marko Pantelic fired over in injury time moments after hauling Serbia back into their final Group D game 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.
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 began the second period with more purpose and they took the lead as Luke 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.