South Africa opening batsman Stephen Cook's second Test century could not prevent Australia from claiming a consolation victory in the day/night clash in Adelaide.
The 33-year-old, playing only his sixth Test, held the Proteas together against the pink ball before he was last man out for 104 of his side's 250 all out, leaving the new-look hosts with 127 to win.
David Warner struck 47, Steve Smith made 40 and debutant Matt Renshaw was unbeaten on 34 as Australia, two years to the day since Phil Hughes died, celebrated a seven-wicket win which ended a run of five Test defeats and denied the tourists a series whitewash.
Resuming the fourth day on 194 for six, a lead of just 70, South Africa lost Quinton de Kock in the fifth over of the day as Australia used a review to overturn a not-out lbw decision by Nigel Llong to hand Jackson Bird his only second-innings scalp.
Vernon Philander and Cook took their side's lead into three figures with a stand of 34 until the former, against the new ball, missed a Mitchell Starc inswinger and was pinned leg-before.
After Cook pulled Josh Hazlewood for four to bring up a 235-ball Test ton, including eight fours, Kagiso Rabada gloved the right-arm seamer behind.
Cook was denied the chance to carry his bat as he was bowled by another inswinger from Starc, who took four for 80 from 23.2 overs, to leave Australia with a small victory target.
Warner dominated an opening stand with the reserved Renshaw, born in Middlesbrough, either side of tea before falling three short of a half-century following a mix-up with his new partner.
The left-hander inside-edged a pull to midwicket and set off for a single only for Renshaw to send him back, leaving Warner stranded as Temba Bavuma and De Kock completed the run out.
South Africa retained hope of another Australia collapse when, with the score still on 64, Usman Khawaja was trapped lbw by Tabraiz Shamsi for a second-ball duck.
But Smith and Renshaw steadied the ship with a partnership of 61 until the skipper edged Kyle Abbott behind with just two required, leaving debutant Peter Handscomb to hit the winning run.