Calm has returned to the streets of Pretoria following a chaotic march against immigrants on Friday..
The home side, who needed 127 for victory, won by seven wickets with a session left on the fourth day to end a run of five defeats.
Cook was last out for a gritty 104 in South Africa’s second innings of 250.
The visitors resumed on 194/6 and were dismissed early in the second hour of the day’s play with Mitchell Starc taking 4/80.
Cook, who was 81 not out at stumps on Saturday, stood firm through the dismissals of Quintin de Kock and Vernon Philander as well as Australia taking the new ball to pull Josh Hazlewood through square leg for four and bring up his second test ton with the last delivery before drinks.
South Africa were all out 14 balls later when Starc nailed Cook’s off stump.
Cook’s 104 came off 240 balls and included eight fours.
David Warner and debutant Matt Renshaw got Australia off to a solid start in their runchase.
But when the partnership was worth 64 miscommunication between the batsmen led to Warne being run out for 47.
Two balls later debutant left-arm wrist spinner Tabraiz Shamsi trapped first-innings centurion Usman Khawaja in front for a duck.
A stand of 61 between Renshaw and Steve Smith, who scored 40, took Australia to within two runs of victory.
They won with four sessions left in the match and with Renshaw 34 not out.
The match was South Africa’s first pink-ball, day/night test and ended a series they had already won 2-0.