The Proteas clinched the five-match ODI series against Sri Lanka after beating the visitors in Bloemfontein on Tuesday.
The Proteas won the third ODI by four runs on the Duckworth Lewis method.
When heavy rain brought an early conclusion to the match, South Africa were 179 for five after 34 overs.
At the start of the last over, they were three runs behind the required run rate but Lasith Malinga bowled a loose over, conceding eight runs, including a wide.
Earlier, Malinga had started magnificently, taking two wickets for 12 runs off his first spell (4-1-12-2), bowling out both Graeme Smith (2) and Colin Ingram (13) leaving the Proteas wobbling on 29 for two.
Tillakartne Dilshan then stuck with his first ball, trapping Alviro Petersen lbw for 17, after an unsuccessful reverse sweep.
Faf du Plessis, coming in at four, and JP Duminy combined for a much-needed 61-run partnership before Duminy was controversially run out.
Du Plessis was also run out after a match-saving 72 runs, but as he was suffering from cramps, he left the crease without any further arguments.
AB de Villiers, who possibly tried one experiment too many in only his third match as captain, batted with Albie Morkel and the pair secured the winning runs, conscious of the onset of rain.
The win gives De Villiers his maiden series victory.
The remaining games will be played in Kimberley and Johannesburg.