Johannesburg, Jan 23: Sri Lanka tailender Sachithra Senanayake smashed a six on the second-last ball for his team to chase down South Africa's total of 312-4 and win by two wickets in the fifth and final one-day international.
Playing in just his second ODI and facing his second delivery on Sunday, Senanayake struck spinner Robin Peterson over midwicket as Sri Lanka lost the series 3-2 but became the first team to score 300 or more to win successive one-dayers since 2007.
AB de Villiers' 125 not out and Graeme Smith's 125 had earlier put South Africa in control at New Wanderers Stadium, adding 186 in 28 overs for for the third wicket.
It was Smith's first ODI hundred since September 2009 to ease the pressure after calls for him to be dropped.
But Kumar Sangakkara (102) and Lahiru Thirimanne (69) put on 100 to get Sri Lanka back into the game before falling late on.
"Graeme and AB batted beautifully and almost put it beyond us, but our openers started brilliantly," Sangakkara said. "Thirimanne also came in and performed. Credit goes to those three guys. Senanayake hitting the winning runs with a six was the icing on the cake."
Sri Lanka's run chase started unusually with Upul Tharanga rather than Tillakaratne Dilshan playing the attacking role. He was unbeaten on 34 out of Sri Lanka's 57-0 when rain came in the eighth over.
No overs were lost despite a break of around an hour, and Tharanga continued where he left off before being removed for 46 by a sensational catch when JP Duminy turned and ran toward the boundary fence and held a diving effort.
South Africa was reduced to 175-3 when Dilshan was caught behind for 41 from a rising delivery from Lonwabo Tsotsobe and Dinesh Chandimal followed soon after in similar fashion for 20 off Wayne Parnell's bowling.
But that brought Thirimanne and Sangakkara together and they were rarely troubled. Sangakkara brought up his century off 96 balls by glancing Albie Morkel for four but he holed out to Duminy two deliveries later.
Thirimanne reached his first ODI half-century moments later but Angelo Mathews, Thisara Perera and Nuwan Kulasekara came and went without offering support as the game turned in South Africa's favor.
When Thirimanne fell off the third ball of the last over, Peterson's second wicket in three deliveries, it seemed to be all over. But that all changed following Senanayake's heroics off the penultimate ball.
In South Africa's innings, Smith and De Villiers came together after Alviro Petersen and Francois du Plessis fell cheaply and accumulated steadily before changing their approach.
Having played the anchor role in reaching his century off 129 balls, Smith then hit two sixes off one over from Senanayake.
Smith picked out the leaping Chandimal at mid-wicket off Lasith Malinga, but De Villiers passed 100 with a huge six then manufactured a couple more to take his side past 300.