South Africa 246 for 6 (De Kock 87, Du Plessis 49, Dananjaya 3-60) beat Sri Lanka 244 for 8 (Mathews 79*, Dickwella 69, Phehlukwayo 3-45) by four wickets
Dambulla: South Africa opener Quinton de Kock's attacking 87 set up a four-wicket win over Sri Lanka in the second one-day international on Wednesday, handing the tourists a 2-0 lead in the five-match series.
Chasing 245 for victory, South Africa reached their target with 43 balls to spare, giving themselves the perfect opportunity to pick up a series win in the 50-over format after going down 2-0 in the test matches.
De Kock and Hashim Amla gave the touring side the perfect platform in their run chase with an opening stand of 91 before spinner Akila Dananjaya dismissed Amla for 43.
Dananjaya, who picked up 3-60, also sent back Aiden Markram soon after but de Kock and South Africa captain Faf du Plessis pegged Sri Lanka back with a 53-run stand for the third wicket.
De Kock hit 13 fours and a six in his 78-ball knock while du Plessis chipped in with a handy 49, before spooning a catch back to Dananjaya to become the off-spinner's third victim.
South Africa lost du Plessis and David Miller in quick succession but once Dananjaya's quota of 10 overs ended, Sri Lanka's attack lacked the teeth to pull off an unlikely victory.
Earlier, half-centuries from captain Angelo Mathews and opener Niroshan Dickwella took Sri Lanka to 244 for eight in their 50 overs after the hosts won the toss and chose to bat.
Pace duo Andile Phehlukwayo and Lungi Ngidi picked up three wickets each as South Africa's bowlers once again managed to prevent Sri Lanka from posting a commanding total.
Ngidi, who took 3-50, provided the early breakthroughs for the tourists by dismissing Upul Tharanga and Kusal Mendis off consecutive deliveries in his opening over.
Dickwella and Mathews steadied the innings with a 67-run stand for the fourth wicket before the former was bowled by Phehlukwayo, who picked up 3-45, for 69.
Sri Lanka failed to add much momentum to their innings as none of their other batsmen managed to cross a score of 20. Mathews remained unbeaten on 79 off 111 deliveries.
The third ODI will be played at Kandy on Sunday.