Pallekele - David Miller has smashed a robust 85 not out off 72 balls to steer South Africa to 223-7 in the third one-day international against Sri Lanka in Pallekele on Friday.
The left-hander smashed five sixes and four boundaries after a three-wicket haul from unorthodox spinner Ajantha Mendis had reduced the tourists to 154-7 in the 42nd over.
South Africa need a win to stay afloat in the five-match series, having lost the first two games in Colombo.
The Proteas, missing star batsman Hashim Amla due to a knee injury suffered in the previous match, had slipped to 100-5 after winning the toss in the day-night match.
Skipper AB de Villiers led the recovery with 47, before Miller pushed the scoring with his fifth one-day half-century, the first by a South African in the series.
Miller put on 69 for the eighth wicket with Ryan McLaren, who remained unbeaten on 14.
Angelo Mathews was back to lead Sri Lanka after serving a two-match suspension for his team's slow over-rates during the recent tri-series in the West Indies.
Sling-arm fast bowler Lasith Malinga provided an early break for the third time in the series when he had Alviro Petersen gloving a catch to the wicket-keeper in the fifth over.
South Africa carried the score to 50-1 in the 14th over when seamer Thisara Perera removed Quinton de Kock and JP Duminy in successive overs to make it 53-3.
Faf du Plessis helped de Villiers put on 42 for the fourth wicket before being run out for 16 after his partner called for a risky single.
Mendis bowled both Farhaan Behardien and Robin Peterson, and had danger man de Villiers caught behind to finish with three for 35 from his 10 overs.
Both sides made three changes from the previous match.
Amla was replaced by de Kock and the visitors also included Behardien and Lonwabo Tsotsobe in place of Aaron Phangiso and Chris Morris.
Sri Lanka: Angelo Mathews (captain), Tillakaratne Dilshan, Upul Tharanga, Kumar Sangakkara, Mahela Jayawardene, Dinesh Chandimal, Angelo Perera, Rangana Herath, Ajantha Mendis, Lasith Malinga, Thisara Perera
South Africa: AB de Villiers (captain), Alviro Petersen, Farhaan Behardien, Quinton de Kock, JP Duminy, Faf du Plessis, Ryan McLaren, David Miller, Morne Morkel, Robin Peterson, Lonwabo Tsotsobe
Umpires: Richard Kettleborough (ENG) and Ranmore Martinesz (SRI)
TV umpire: Rod Tucker (AUS)
Match referee: Andy Pycroft (ZIM)