Skipper Ab de Villiers supported Miller with a gritty 47 and put on 48 runs with Miller for the sixth wicket.
Coming to bat down the order, David Miller top-scored for South Africa with 85 and gave his side a respectable total.
Ajantha Mendis picked up three wickets giving away 35 runs. His victims included Ab de Villiers, Fahad Behardien and Robin Peterson.
Thisara Perera had figures of 2/51 from his eight overs.
Defending 224 to stay alive in the ODI series, Lonwabo Tsotsobe provided the perfect start for South Africa scalping Dilshan (6), Sangakkara (0) and Upul Tharanga (5) in his first spell to leave Sri Lanka reeling at 16 for 3. TsoTsobe finished with figures of 7-2-22-4. (AFP Images)
Mahela Jayawardene (24) and Dinesh Chandimal (29) tried to rebuild the innings with a 55-run stand but the duo departed in quick succession as the hosts lost four wickets for just 22 runs in the middle overs. (AFP Images)
Thisara Perera then sparked off a late resurgence clobbering Robin Petersons one over for 35 runs and ended up scoring 65 off 59 balls. Rangana Herath and Perera combined for a 71-run stand for the 8th wicket. (AFP Images)
Medium pacer Farhaan Behardien dismissed the dangerous looking Perera in the 43rd over as he ended with three scalps. South Africa won the 3rd ODI by 56 runs restricting Sri Lanka to 167. (AFP Images)