Sachithra Senanayake struck a six off the penultimate ball to give Sri Lanka a two-wicket triumph over South Africa on Sunday in the final match of a five one-day international series won 3-2 by the hosts.
Captain AB de Villiers and predecessor Graeme Smith (125 each) struck tons as South Africa made 312-4, but a century from Kumar Sangakkara (102) led the tourists to 314-8 at the Wanderers and a second win within three days.
Sri Lanka appeared to be cruising until Sangakkara became the fourth wicket to fall with 275 runs on the board and a late South Africa rally saw them grab two wickets within three balls during the final over.
It left the tourists needing five runs from two balls to succeed and Senanayake hit Robin Peterson for a six to snatch victory in a thrilling climax to the two-month tour.
Sangakkara struck 10 fours in a maiden ODI ton against South Africa and there were also valuable contributions from Lahiru Thirimanne (69), Upul Tharanga (46) and skipper Tillakaratne Dilshan (41).
De Villiers and Smith excelled as South Africa recovered from a sluggish early run rate having being sent in to bat by Dilshan in a match delayed for one hour by rain early in the Sri Lankan innings.
De Villiers finished unbeaten after facing 98 deliveries while Smith received a standing ovation from the sell-out 30,000 crowd after being caught by Dinesh Chandimal at mid-wicket off the bowling of Lasith Malinga.
While the Proteas skipper confirmed his position as one of the best stroke players in the world today with 10 fours and four sixes, Smith could not contain his joy as he walked off after a timely first ODI ton in three years.
There was a media and public outcry against him just a week ago after innings of six, 28 and two in the first three matches of the series before he stopped the rot with a brisk 68 in Kimberley two days ago.
Smith embroidered his innings with nine fours and four sixes off 143 balls during a 203-minute stand and the sun-drenched crowd revelled in his change of fortune.
South Africa lost opener Alviro Petersen (6) with only 10 runs on the board and were 70-2 when Faf du Plessis (24) departed before De Villiers and Smith took charge.
The Proteas stood at 133-2 after 30 overs and a run rate of 4.43 needed improvement on a good batting track, which the captains past and present duly did with 44 runs coming during a power play soon after.