But the win came at a cost. Mathews said at the after-match presentation that he could miss the rest of the tour after twisting his right ankle when he dived to avoid being run out in the penultimate over.
“It’s pretty bad, I think I will be out for a couple of weeks,” said Mathews, who made 54 not out as Sri Lanka chased down a low South African total of 113 with two balls to spare.
The third and final Twenty20 international will be played in Cape Town on Wednesday, followed by five one-day internationals, finishing on February 10.
On an unusually dry, slow Wanderers pitch, South Africa were bowled out in 19.3 overs.
Left-arm wrist spinner Lakshan Sandakan, playing in his first T20 international — although he has played in three Test matches and a one-day international — took four for 23 and bamboozled the South African batsmen with his ability to spin the ball both ways.
Seamers Isara Udana and Nuwan Kulasekera took three for 13 and two for 10 respectively. Heino Kuhn top-scored for South Africa with 29.
New fast bowling discovery Lungi Ngidi gave South Africa hope of defending their low total, taking four for 19.
Ngidi, who was man of the match when South Africa won the first game in Centurion, took three wickets in an electrifying three-over opening spell, then came back to take another wicket in the 15th over, at the end of which Sri Lanka were 89 for four.
It came down to eight needed off the last seven balls when man of the match Mathews was injured after a risky leg bye. He managed to hobble a single off Wayne Parnell’s last ball to keep the strike.
Mathews went for a big hit off the first ball of the last over, bowled by left-arm spinner Jon-Jon Smuts, and was dropped by a diving Heino Kuhn at deep midwicket.
He did not take a run. He hit the next ball for six to level the scores and two balls later finished the match with another six.
“I had to hit sixes because I couldn’t run,” he said.
South African captain Farhaan Behardien said: “On a deck that was a little bit slow, Sri Lanka kept taking wickets and we couldn’t launch at the end.
“We were put under pressure today. But the guys really fought hard and I’m proud of them.” (Courtesy AFP)