Cahill, who missed his side's last match after being sent off against Germany, headed home a Luke Wilkshire cross from the right flank in the 69th minute to give Australia the lead against the run of play.
Brett Holman then added a second with a fine long-range strike in the 73th minute.
Serbia poured forward in the last few minutes and pulled a goal back in the 84th minute. A long range shot from Zoran Tosic was spilt by Australian goalkeeper Mark Schwarzer, leaving Marko Pantelic with the simple task of tapping in the rebound.
Two minutes later it looked as if Pantelic had equalised but his effort was ruled out for offside.
Serbia also had a strong claim for a penalty as the game wound down with Cahill appearing to handle the ball. Another Serbian goal would have put them through to the second round.
"The referee, including the fourth official, did not want to see a foul that was quite obvious. We are angry when it came to this decision," Serbian coach Radomir Antic said.
"We did not get fair treatment, we deserved more than we did get and we have to go home now. The ref had a black day when it came to Serbia," he added.
The Serbians had dominated the first half but failed to take their opportunities.
Milos Krasic squandered their first chance, rounding Schwarzer in the Australian goal after 12 minutes before skewing his shot wide and high.
Schwarzer produced a fine reflex save to block a close range effort from Branislav Ivanovic midway through the half, and 10 minutes later the giant figure of Nikola Zigic should have scored when left unmarked inside the box, but glanced his header well wide of goal.
The pacy Krasic, who was a menace on the Serbian right flank all evening, slipped though the Aussie defence after 38 minutes and squeezed the ball under Schwarzer into the net, but his effort was ruled out for offside.
The Aussies revived in the second half and Mark Bresciano finally tested Serbian goalkeeper Vladimir Stojkovic with a long-range shot after an hour.
With time running out, Australia coach Pim Verbeek threw on two substitutions and it seemed to give the Aussies the lift they needed.