De Villiers, the newly appointed South African ODI captain, was again the man of the series with 329 runs at an average of 109.66.
After winning the toss and electing to field, South Africa's opening bowlers struck early, with Dale Steyn and Vernon Philander taking the wickets of Tillakaratne Dilshan and Kumar Sangakkara respectively.
[8] By the end of the first day, South Africa had reached 90 runs, half of Sri Lanka's first innings total, for the loss of one wicket, and captain Graeme Smith had scored a half-century.
Substitute fieldsman Dimuth Karunaratne claimed to have caught him at backward point, although replays showed the ball may have hit the ground before sliding into his fingers.
De Villiers elected to accept Karunaratne's word and, one run short of his 13th Test century, decided against referring the dismissal for a video review.
Petersen was selected to open the batting, relegating Jacques Rudolph to occupy Prince's position at number six in South Africa's line-up.
[16] Sri Lanka replaced injured bowler Dilhara Fernando with Dhammika Prasad, and dropped opener Tharanga Paranavitana for Lahiru Thirimanne.
[17] Sri Lanka won the toss and elected to bowl, a decision called into question when South Africa ended the first day at 3/347.
Needing 341 to avoid an innings defeat and force South Africa to bat again, Sri Lanka reached 342 after a century to Thilan Samaraweera (115 not out).
[20][21] The first of the five matches in the ODI series, held at Boland Park, Paarl, marked the debut of AB de Villiers as South Africa's captain in the format.
Jacques Kallis (72) and de Villiers (52) each scored half-centuries before the team's progress was halted by a late run of wickets taken by Lasith Malinga.
[24] Sri Lanka's captain Dilshan said after the match that it was the "worst game of my career", and defended the exclusion of Thilan Samaraweera, the team's top batsman in the recently concluded Test series, from the ODI squad.
Rangana Herath replaced fellow spinner Ajantha Mendis, while pace bowler Dhammika Prasad was called up to play in the place of Dilhara Fernando.
South Africa started their run chase badly, with the early loss of Graeme Smith and Colin Ingram to the bowling of Lasith Malinga.
Faf du Plessis recovered South Africa's prospects; promoted to fourth in the batting lineup, he scored 72 off 74 balls before being run out.
Quick scoring from JP Duminy and AB de Villiers helped take South Africa to 5/179 when rain struck after 34 overs.
[31] South Africa rested Dale Steyn and Albie Morkel for the dead rubber fourth match of the series, calling up Wayne Parnell and Vernon Philander in their places.
[32] South Africa's Test captain Graeme Smith had been under pressure to retain his position in the ODI side after a string of mediocre performances with the bat.
Perera's fast scoring ensured Sri Lanka reached the target in the 49th over, avoiding a series whitewash.
[33] Having been sent into bat by Sri Lanka, South Africa scored 312 off 50 overs, thanks to centuries from Graeme Smith and AB de Villiers (both 125).
Sri Lanka chased down the total with one ball to spare, making it the second time in ODIs that a team had successfully reached a target of 300 or more in consecutive matches.