Five-eighth Quade Cooper also showed some tantalising flashes of his best and clearly relished his return to his home town in front of 30,327 supporters.
Importantly, Australia's set piece held up against the might of the Springboks, winning the scrum battle and losing only one lineout - a marked turnaround from the two listless Bledisloe Cup defeats.
But there were some bad early signs with Warren Whiteley providing the tourists' first try inside the opening three minutes.
Then in the 18th minute, just as the Wallabies seemed certain to score themselves, Springboks skipper Adriaan Strauss picked off Foley's pass and dispatched to playmaker Elton Jantjies.
He kicked ahead into open space for an on-rushing Johan Goosen to score untouched, giving them an 11-point lead.
Coleman crashed over just before the half-hour mark, courtesy of a smart pop-up ball to the left corner from Will Genia, to begin the Australian fightback.
Then penalties to Foley either side of halftime - the second after a yellow card to lock Eten Eztebeth - gave Australia a slender 16-14 edge.
Samu Kerevi had the chance to take full advantage of the sin-binning but was too casual as he bore down on the line in the 47th minute and was held up by fullback Goosen.
Instead, it was left to Foley, who dummied through the Springboks' line to cap off an 18-phase play in the 62nd minute, to finish them off.
Australia 23 (A. Coleman, B Foley tries; Foley 2 cons 3 pens)
South Africa 17 (J. Goosen, W. Whiteley tries; E. Jantjies 2 cons, M. Steyn pen).
Halftime: 13-14.