After sending the tourists into bat, the home side restricted Sri Lanka to 134 for seven in their 20 overs.
South Africa's veteran leg-spinner Imran Tahir conceded only five runs in a decisive super over as they beat Sri Lanka in their opening Twenty20 International on Tuesday after both teams had finished their innings with the same score.
After sending the tourists into bat, the home side restricted Sri Lanka to 134 for seven in their 20 overs, but then blew a commanding position to end with same total, leaving the Newlands encounter to be decided by a one-over eliminator.
David Miller helped South Africa blast 14 runs from their super over, before the wily Tahir restricted Sri Lanka to only five in reply, two of which were wides.
South Africa looked odds-on for victory when they reached 118 for three in their innings, needing 17 runs from 22 balls, but a flurry of late wickets left them needing two off the last delivery with Tahir on strike.
He missed the ball from seamer Isuru Udana, but partner Dale Steyn scrambled through for a single as Sri Lanka wicketkeeper Niroshan Dickwella botched a simple run out to win the game for his side.
Miller had earlier struck a quickfire 41 off 23 balls and put on 66 for the fourth wicket with Rassie van der Dussen (34) as the pair steadied the innings after the home side had lost three early wickets.
But Sri Lanka captain Lasith Malinga took the game into the final over with a superb spell of bowling, ending with figures of 2-11 in four overs.
Kamindu Mendis top-scored for visitors in their innings, blazing 41 off 29 balls before he was stumped by stand-in wicketkeeper Miller off the bowling of the impressive Tahir.
Miller was handed the gloves as South Africa seek a back-up option to Quinton de Kock at the World Cup in England and Wales, with the former passing his audition with some neat work behind the stumps.
The second match in the series will be played in Pretoria on Friday, before concluding on Sunday in Johannesburg.