Centuries from Quinton de Kock and AB de Villiers earned South Africa a first-ever one-day international series win in Sri Lanka as they sealed victory in the third ODI at Hambantota by 82 runs.

De Kock made 128 and De Villiers an explosive 108, putting on 116 for the third wicket, as the Proteas posted an imposing total of 339 for five.

And it proved too much for Sri Lanka as Ryan McLaren's three wickets helped dismiss them for 257.

Hashim Amla and De Kock got the tourists off to a flying start and had already taken them to 118 by the time Rangana Herath made the breakthrough to remove Amla for 48.

He struck again to trap Jacques Kallis lbw for just four, but it only brought De Villiers to the crease and the captain's partnership with De Kock took the match away from the hosts.

De Kock, who was dropped on 37 by Ashan Priyanjan, hit 12 fours and three sixes in his 127-ball knock before falling to Sachithra Senanayake, caught at mid-on by Ajantha Mendis, with his team on 248.

De Villiers turned up the power with JP Duminy (29) at the crease and the pair put on 80 in eight overs.

De Villiers, who brought up his 17th ODI ton in 66 balls, smashed 11 fours and four sixes in his 71-ball innings, which was finally ended when Priyanjan took a catch at deep cover off Mendis.

Sri Lanka's top three all got starts, but were unable to go on.

Kusal Perera made 37, Tillakaratne Dilshan 30 and Kumar Sangakkara 36 as the Proteas took wickets at steady intervals to turn up the pressure.

Sangakkara was McLaren's first victim, wicketkeeper De Kock taking the catch down leg side, and when Mahela Jayawardene was dismissed for just two, the hosts had gone from 113 for two to 113 for four.

A battling 58 from captain Angelo Mathews held up the South African charge, but he too was undone by McLaren.

McLaren's third wicket was Priyanjan for 30 and from then on the game was up and the hosts were dismissed inside 45 overs.