Sri Lanka 99 for 7 v (Chandimal 36*, de Silva 31, Dala 2-22, Rabada 2-24, Shamsi 2-26) beat South Africa 98 (de Kock 20, Sandakan 3-19, Akila 2-15, de Silva 2-22) by three wickets
Sri Lanka ended South Africa's tour of the island as they started it: by strangling their visitors with spin to win the only T20I in front of a sell-out crowd. But they made hard work of a small chase and lost seven wickets in a tense low-scoring affair, which also served as Dinesh Chandimal's comeback match.
Chandimal was returning from a six-game suspension and played as though he had never been away. He was there at the end and held firm through sustained pressure from the South African pack to see Sri Lanka home. Kagiso Rabada built up a good head of steam, Junior Dala used the short ball well and Tabraiz Shamsi claimed a T20I best of 2 for 26 but their batsmen had not given them enough to work with.
South Africa slumped to another batting low; after being dismissed for their lowest Test score since readmission (73) and lowest ODI score in Sri Lanka (121), they were bowled out for their lowest T20I score and literally fell on their sweeps. As a collective, South Africa's approach to spin appears to have 99 problems and needs more than an annual camp to India to solve.
South Africa's innings started promisingly when Quinton de Kock took three boundaries off the opening over - and only one of them was laced with luck. De Kock inside-edged the first ball from Kasun Rajitha past leg stump before stroking two gorgeous drives.
But the sign of things to come was clear in the next over. De Kock was almost run-out at the non-striker's when Hashim Amla sent him back after initially agreeing to a single. Amla was caught at extra-cover two balls later, trying to scoop a Dhananjaya de Silva delivery over the in-field and bagged a second duck in succession and third on the tour and South Africa's slide started. De Kock was run out in the next over, trying to sneak a leg bye after he failed to connect to a slog-sweep and he finished as South Africa's top scorer.
Reeza Hendricks' 29th birthday celebrations were limited to a six off a de Silva half-tracker and back-to-back boundaries off Rajitha before he tried to sweep an Akila Dananjaya's legbreak, which turned away to hit the top of off stump.
Rain interrupted the innings for two minutes at the end of the seventh over, but did not change South Africa's fortunes. JP Duminy was out lbw on review when he missed a reverse-sweep, giving David Miller the opportunity to build an innings. But that chance was taken away in Lakshan Sandakan's third over, a triple-wicket maiden.
Heinrich Klaasen tried to send a wrong'un over the covers but outside-edged to point, Andile Phehlukwayo pulled out a reverse-sweep off the fourth ball he faced and dragged it onto his stumps, and Kagiso Rabada was struck on the back pad as he misread a googly. Rabada reviewed, in vain.
South Africa were 73 for 7 after 11 overs and Miller only had the tail to work with. Under pressure, he tried to sweep Akila but top-edged to short midwicket to leave South Africa in shambles.
Sri Lanka would have had some early nerves when Kagiso Rabada struck twice in the opening over of their reply. Kusal Perera gifted Tabraiz Shamsi a catch at mid-on and Kusal Mendis was out lbw on review to an inswinging yorker that would have gone on to hit leg stump.
De Silva counterpunched with a pull behind square in Rabada's next over to get Sri Lanka going. He went on to plunder 14 runs off Lungi Ngidi's second over, a top-edge over third man for six and drives off the front and back foot.
Chandimal got in on the act when he flicked a low Rabada full-toss for four and then showed South Africa how to sweep successfully, smacking a six and a four off Shamsi. The de Silva-Chandimal partnership grew to 53, giving Sri Lanka more than half of what they needed to win, when they were rocked again.
De Silva did not get hold of a Junior Dala short ball and gave Phehlukwayo a simple catch at midwicket and five balls later Angelo Mathews was out for a duck, brilliantly caught by Klaasen at short leg, diving one-handed to his left.
Dasun Shanaka joined Chandimal and played with the same aggression he showed in his ODI cameos. He struck a hat-trick of boundaries off Shamsi but holed out to deep square leg off a Dala short ball. Shamsi had one more moment in the spotlight, when he burst through Thisara Perera's defences with a googly.
South Africa would only really have started believing when stand-in captain Duminy brought himself on in the 15th over and took a wicket with his first ball. Duminy bowled a slider, Akila tried to smash it through the covers and middle stump was rocked. Sri Lanka only needed 11 runs to win at that stage, though, and Chandimal kept his cool to rotate strike before Isuru Udana drove Ngidi down the ground to end the match with four overs to spare.
Firdose Moonda is ESPNcricinfo's South Africa correspondent