Hosts South Africa won the toss and elected to bat but were bowled out for 113 by the tourists three balls before the end of their innings at The Wanderers.
Sri Lanka were rocked by an early burst from exciting 20-year-old fast bowler Lungisani Ngidi (4-19), but chipped away at the target and completed the win with two balls left as captain Angelo Mathews led the way with an unbeaten 54 from 50 balls.
Sri Lanka's Lakmal claims first Test wicket of 2017
The deciding match in the three-game series will be played in Cape Town on Wednesday.
South Africa's batsmen struggled from the start with only opener Heino Kuhn (29) and captain Farhaan Behardien (27) offering anything of substance as the home side managed just nine fours and two sixes in their innings.
Sri Lanka's bowling attack produced an excellent line that made scoring difficult, with Sandakan (4-23) and seamer Isuru Udana (3-13) doing most of the damage.
Sri Lanka's Lakmal claims first Test wicket of 2017
Sandakan became the first Sri Lankan to take a wicket off his first ball in T20Is when he had Mangaliso Mosehle caught by wicketkeeper Dinesh Chandimal for 11.
Fast bowler Ngidi, who made his debut in South Africa's 19-run win in the first match of the series in Pretoria on Friday, was again impressive as he accounted for the top-four batsmen.
But Mathews provided the glue to keep Sri Lanka's chase together with an excellently paced innings and delivered the killer blow.
He was hobbling with cramp when the tourists needed seven off the last over bowled by spinner Jon-Jon Smuts and, after being dropped off the first ball, launched the second delivery into the stands for a six to level the scores. Another blow over the boundary rope two balls later handed Sri Lanka a much needed victory.
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