The final score was 26-19 after the Aussies took a 7-5 lead at the break, with Selvyn Davids' try cancelled out by a converted try by Nathan Lawson from a restart error, but the Springbok Sevens took control of the match in the second half.
Two quick tries by Zain Davids, both converted by Tristan Leyds, coupled with a red card to Nick Malouf for a dangerous tackle on Tiaan Pretorius, put the Blitzboks in control at 19-7.
However, the Aussies were not done yet and scored two late tries, one of which was converted, to pull level on the scoreboard.
From the last restart, with second left on the clock, the Blitzboks created space on the left with Selvyn Davids racing away down the left touchline before unselfishly giving the ball to Shaun Williams behind the posts to score the match - and medal - winner.
Earlier on Saturday, South Africa succumbed to second half pressure by France in their semi-final and lost by 19-5.
The scores were tied at 0-0 at the break but France, spurred on by a full house at the iconic stadium, scored three consecutive tries after the Blitzboks took a 5-0 lead early in the second half.
It was a helter skelter first half, with both teams battling the rain that came pelting down, and some nervous and determined defence. France came close twice and the Blitzboks once, but on each occasion defence ruled.
Not so at the start of the second half though when Tristan Leyds scored after some good recycling by his Blitzbok team mates.
France, who introduced local hero Antoine Dupont on the field just before the try, then managed three tries, two from mistakes by the South Africans, to book their spot in the final.
Dupont underlined his class with two late tries as the French took gold after smashing Fiji, Olympic champions in Rio and Tokyo, by 28-7 in the final.
Scorers:
South Africa 26 (5) Australia 19 (7)
SA - Tries: Selvyn Davids, Zain Davids (2), Shaun Williams. Conversions: Tristan Leyds (2), Siviwe Soyizwapi.
Australia - Tries: Nathan Lawson, Corey Toole, Henry Paterson. Conversion: Dietrich Roache (2).
South Africa 5 (0) France 19 (0)
SA - Try: Tristan Leyds.
France - Tries: Rayan Rebbadj (2), Jordan Sepho. Conversions: Rebbadj (2).