Warren Whiteley and Johan Goosen went over to give South Africa an early lead before an Adam Coleman try reduced the arrears to 14-13 at the break.
Eben Etzebeth was shown a yellow card for the visitors just after the restart then Bernard Foley scored a crucial try to seal a morale-boosting win.
Earlier on Saturday, New Zealand beat Argentina to stay top of the table.
The Wallabies, who stay bottom, eventually opened their account in this year's championship after back-to-back defeats by the All Blacks.
They have had their troubles since losing the World Cup Final to New Zealand at Twickenham in October.
A 3-0 series defeat to England and those defeats to New Zealand had put pressure on coach Michael Cheika.
Many Wallabies fans voted with their feet and the Suncorp Stadium was half empty as the Springboks heaped on further misery in the opening minutes.
Whiteley barged over for his third international try, then Goosen dived over after Adriaan Strauss intercepted a Quade Cooper punt.
There were boos around the stadium with the Wallabies trailing 14-3, but they were soon silenced as a high pass from Will Genia picked out Coleman who went over in the corner.
The home side carried the momentum into the second-half and Foley gave them the lead for the first time with a penalty after Etzebeth was sin-binned for a challenge.
Samu Kerevi thought he had gone over in the corner for the Wallabies but his knee was adjudged to have been in touch before he grounded the ball.
The Wallabies were now under the cosh and Foley gave the home side some breathing space when he dived over after a dummy pass.
Australia: Folau, Haylett-Petty, Kerevi, Foley, Hodge, Cooper, Genia, Pocock, Hooper, Mumm, Coleman, Douglas, Kepu, Moore, Sio. Replacements: Polota-Nau, Slipper, Alaalatoa, Arnold, McMahon, Phipps, Kuridrani, Mitchell.
South Africa: Goosen, Habana, Kriel, de Jongh, Hougaard; Jantjies, de Klerk; Whiteley, Mohoje, Louw, de Jager, Etzebeth, Adriaanse, Strauss, Mtawarira. Replacements: Mbonambi, Kitshoff, Nyakane, Mostert, du Toit, Kriel, Steyn, Mapoe.
Australia ended a six-match losing run with a 23-17 victory over South Africa in the Rugby Championship in Brisbane.