David Miller hit two sixes in the last over as South Africa shrugged off a hat trick from Wanindu Hasaranga to beat Sri Lanka by four wickets at the T20 World Cup on Saturday.
Quinton de Kock returned after declining to play the last game against West Indies when the South Africa players were ordered to take a knee for the Black Lives Matter movement.
He made 12 and took a knee alongside all the other players on the field ahead of the start.
Read: Shakib, Sohan uncertain for SA clash
Miller launched his late attack, with support from Kagiso Rabada, to lift South Africa from 112-6 in the 18th over to 146-6 and beyond the target of 143 with one ball to spare.
Miller finished with 23 not out from 13 balls and Rabada hit the winning boundary — an edge past the wicketkeeper for four — having also blasted a six in the penultimate over to keep South Africa on track.
The Proteas needed 15 off the final over and Miller launched maximums off the second and third balls from Lahiru Kumara.
Read: Please buy T20 World Cup tickets, pleads Afghanistan captain
South Africa's cause was boosted by captain Temba Bavuma's top score of 46, but he was also the second wicket in Hasaranga's hat trick.
Hasaranga removed Aiden Markram off the final ball of a previous stint, and then Bavuma and Dwaine Pretorius in consecutive balls of a new spell.
Earlier, Sri Lanka finished on 142 all out in its 20 overs after 72 in 58 balls from opener Pathum Nissanka.