Left-handed opener Kusal Perera hit a 40-ball 61 to lift Sri Lanka, who won the toss and batted, to 165-7 before restricting South Africa to 160-5.
The victory gave Sri Lanka an ideal start to the group one campaign in the Super-10 stage at Zahur Ahmed Chowdhury stadium.
South Africa needed 15 off the final over but Lasith Malinga kept a tight line and despite a last ball six by tail-ender Imran Tahir, Sri Lanka carried the day.
South Africa were given a flying 32-run start by Quinton de Kock (25) and Hashim Amla (23).
Jean-Paul Duminy (39) and AB De Villiers (24) hit Ajantha Mendis out of the attack with 22 runs in his first two overs but both departed within nine runs to give Sri Lanka the edge.
David Miller (19) and Albie Morkel (12) briefly threatened, with Morkel hitting two successive sixes but Sri Lanka pulled off the win.
Sri Lanka captain Dinesh Chandimal praised Perera and the death bowling.
"Everyone is over the moon," said Chandimal. "I am full of beans again. Kusal hit some good boundaries to get us a good start and Mathews finished it off well. Our death bowling with Lasith (Malinga) was very good."
South Africa skipper De Villiers rued their loss of wickets at regular intervals.
"We lost wickets at crucial time and that stopped the momentum," said De Villiers. "We weren't good enough."
Earlier, Perera and Mathews gave Sri Lanka total some stability.
Perera hit six boundaries and three towering sixes before leg-spinner Imran Tahir pulled back the scoring rate by taking 3-26 in his four overs.
Mathews gave the final touches to the innings by hitting three boundaries and a six to help Sri Lanka add 45 in the last five overs.
Paceman Dale Steyn, declared fit after recovering from a hamstring injury, finished with 2-37 while fellow pacer Morne Morkel grabbed 2-31.
Sri Lanka's most experienced trio of Tillakaratne Dilshan (nought), Mahela Jayawardene (nine) and Kumar Sangakkara (14) failed to supplement Perera.
South African captain Faf du Plessis was ruled out of the match as he was unable to recover fully from a hamstring injury and was replaced by De Villiers as captain.
Steyn was in the thick of things from the first over as he was hit for two fours and a six by Perera before the paceman bowled the other opener Dilshan on the last delivery.
Perera went onto make his fifth T20 half-century off 29 balls before he holed out in the deep off Tahir.
England play New Zealand in the same group later Saturday. The Netherlands are the third team in the group.
Top two teams from each group will qualify for the semi-finals.
The final of the event will be played in Dhaka on April 6
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ