It was the first time in 19 years and 327 days that the Proteas have beaten Sri Lanka in their backyard.
After winning the toss, Proteas captain, AB de Villiers elected to bat.
David Miller was the star of the Proteas' innings, smashing a robust 85 not out off 72 balls to steer South Africa to 223-7 in their alotted 50 overs.
The left-hander smashed five sixes and four boundaries after a three-wicket haul from unorthodox spinner Ajantha Mendis had reduced the tourists to 154-7 in the 42nd over.
"It's hard to explain how proud I am of the boys," de Villiers said.
"It was not easy and we were under pressure through the game.
"It was a really good performance.
"But we did not have enough partnerships going."
The Sri Lankan run chase got off to a circumspect start as openers, Tillakaratne Dilshan and Upul Tharanga found it difficult to get the Proteas opening bowling pair of Lonwabo Tsotsobe and Morné Morkel off the square.
The pressure eventually told as Tsotsobe got Dilshan to loft a mistimed drive straight to De Villiers, who was at mid-off.
Tsotsobe would soon strike again, removing the in-form Kumar Sangakkara for a duck as he scooped one to JP Duminy in the covers as the score stood at 14-2.
It would soon be 16-3 as Tharanga finally folded to the pressure, edging a Tsotsobe delivery to Alviro Petersen in the slips with seven overs already being bowled.
With the pitch slowing up and conditions aiding movement through the air, Mahela Jayawardene and Dinesh Chandimal sought to steady the Sri Lankan ship, putting on a 55-run partnership for the fourth wicket, with Jayawardene surviving an unsuccessful LBW review when Robin Peterson managed to strike him on the pads with the score on 39-3.
However, Peterson would eventually get his man, bowling Jayawardene through the gate for 24 as Sri Lanka struggled to 71-4 at the halfway point in their innings.
Jayawardene's departure sparked a mid-innings collapse.
With Ryan McLaren into the attack and varying his pace well, he soon removed the established Chandimal for 29, a mere seven runs later, as the Knights all-rounder got Chandimal to edge one to Quinton de Kock, who made no mistake behind the stumps.
Peterson was replaced by Behardien in the attack and the Titans batsmen got straight into the action dismissing Angelo Perera for a single and Sri Lanka teetering on 81-6.
Tsotsobe was then reintroduced into the attack and grabbed his fourth of the match to remove the prized scalp of Angelo Mathews for 14 as the Sri Lankan captain mistimed a lofted drive to his counterpart De Villiers in the covers and leave Sri Lanka on 93-7 (30.5 overs).
The Proteas could have been forgiven that the hard work was done, but Thisara Perera had other ideas as he smashed Peterson for 35 runs in the 33rd over, hitting five sixes and a four, with Peterson bowling a wide in between, to give the hosts a glimmer of hope.
It was the second most expensive over in ODI history, just one run short of Herschelle Gibbs' total demolition of the Netherlands' Dan van Bunge in 2007.
He is turning out to be a good all-rounder," said Mathews in his post-match interview.
"The pitch was not easy to bat on, but it looked as if Thisara was batting on a different wicket."
Perera continued to torment the Proteas attack with Rangana Herath providing adequate company at the other end.
Perera was given a lifeline as he was dropped on 61 by Tsotsobe off the bowling of Morkel.
The two put on 72 runs together in just over 11 overs before Perera skied one too many as he was caught in the deep by Faf du Plessis to hand Behardien his second wicket of the match and perish for a 49-ball 65.
"With Thisara playing so well, I should probably have stayed there with him" added Mathews.
"We need to get everything together on Sunday."Behardien would only wait five more balls to grab his third, bowling Lasith Malinga for a duck as the tail-ender tried to slog one into the deep with the score at 166-9.
Duminy ensured that the Proteas would not have to wait long to taste victory once again as he captured Mendis after the No. 11 scooped one to Tsotsobe, who made amends for his earlier error and hand the Proteas victory against Sri Lanka on Sri Lankan soil for the first time in almost 20 years.
The Proteas, missing star batsman Hashim Amla due to a knee injury suffered in the previous match, had slipped earlier slipped to 100-5 in their innings.
Skipper De Villiers led the recovery with 47, before Miller pushed the scoring with his fifth one-day half-century, the first by a South African in the series.
Miller put on 69 for the eighth wicket with McLaren, who remained unbeaten on 14.
Mathews was back to lead Sri Lanka after serving a two-match suspension for his team's slow over-rates during the recent tri-series in the West Indies.
Sling-arm fast bowler Malinga provided an early break for the third time in the series when he had Petersen gloving a catch to the wicket-keeper in the fifth over.
South Africa carried the score to 50-1 in the 14th over when seamer Thisara Perera removed De Kock and Duminy in successive overs to make it 53-3.
Faf du Plessis helped de Villiers put on 42 for the fourth wicket before being run out for 16 after his partner called for a risky single.
Mendis bowled both Behardien and Peterson, and had danger man De Villiers caught behind to finish with three for 35 from his 10 overs.
Both sides made three changes from the previous match.
Amla was replaced by de Kock and the visitors also included Behardien and Tsotsobe in place of Aaron Phangiso and Chris Morris.
Sri Lanka: Angelo Mathews (captain), Tillakaratne Dilshan, Upul Tharanga, Kumar Sangakkara, Mahela Jayawardene, Dinesh Chandimal, Angelo Perera, Rangana Herath, Ajantha Mendis, Lasith Malinga, Thisara Perera
South Africa: AB de Villiers (captain), Alviro Petersen, Farhaan Behardien, Quinton de Kock, JP Duminy, Faf du Plessis, Ryan McLaren, David Miller, Morné Morkel, Robin Peterson, Lonwabo Tsotsobe
Umpires: Richard Kettleborough (ENG) and Ranmore Martinesz (SRI)
TV umpire: Rod Tucker (AUS)
Match referee: Andy Pycroft (ZIM)