Kumar Sangakkara compiled a well-paced century to help Sri Lanka to a two-wicket win over South Africa off the penultimate ball in the fifth One-day International at the Wanderers on Sunday.
Sangakkara scored 102 from 97 balls as Sri Lanka, chasing South Africa's 312 for four, reached 307 for five with only six runs needed off seven balls.
But they contrived to lose three wickets in the space of four deliveries before Sachithra Senanayake struck left-arm spinner Robin Peterson high over mid-wicket for six.
South Africa, who won the series 3-2, owed their total to captain Graeme Smith and AB de Villiers who each scored 125.
Sangakkara anchored Sri Lanka's run chase, reaching his fifty off 54 balls before posting his 12th one-day international.
After striking 10 fours, he fell to the first ball following the completion of his hundred when he hoisted a delivery from off-spinner JP Duminy to Pietersen at long-off.
Play was delayed for an hour before Sangakkara and fellow left-hander Lahiru Thirimanne added 100 runs for the fourth wicket on a good batting pitch.
Sangakkara departed with the score on 275 for four with the tourists needing just 38 runs off 34 balls and 22-year-old Thirimanne brought up his maiden ODI fifty on his way to 69 at better than a run a ball to set up the tense finish.
The result would have been particularly hard on Smith and De Villiers who had batted superbly during their team's innings.
The pair combined for a South African record third-wicket partnership against Sri Lanka of 186 from 28 overs.
Smith, who had not scored an ODI century since September 2009, reached his ninth one-day century off 129 deliveries to the raucous applause of the home crowd.
He struck nine fours and four sixes during his 143-ball innings before he was caught at mid-wicket off a delivery from paceman Lasith Malinga.
De Villiers has been in sublime touch during the series, scoring 329 runs in five matches, and he continued his good form with an innings full of innovative strokeplay, which took only 98 deliveries.
The South Africa skipper brought up his 12th ODI century off 88 balls. He struck 10 fours and four sixes.