Miller, Tsotsobe keep series alive
South Africa 223 for 7 (Miller 85*, Mendis 3-35) beat Sri Lanka 167 (Thisara 65, Tsotsobe 4-22) by 56 runs
Scorecard and ball-by-ball details
What a difference two overs can make. That was all it took for South Africa to stay alive in the series, have their confidence restored and beat Sri Lanka at home for the first time in close to 20 years.
The 49th and 50th over of their innings produced 38 runs and took their total from middling to challenging. David Miller scored 35 of them himself - prior to this match no South African batsman had managed a score greater than 29 in the series - hitting Thisara Perera and Lasith Malinga straight down the ground. He proved South Africa could be competitive and could come back after being under pressure in the first two matches, and even large sections of the third.
And what a difference an over can almost make. Perera hit Robin Peterson for the second-most expensive over in ODI cricket to throw Sri Lanka back into contention after they slumped to 93 for 7. The 35 runs included five sixes and a four, Perera displaying his prowess, especially over the leg-side.
Like Miller, he showed the temperament required to succeed in conditions where the surfaces are sluggish - survive first, thrive later. Unlike the South African, Perera was asked to do too much at the end.
Because Miller did not have a target to chase, he had less pressure on him. His strike rate hovered between 70 and 80 for most of his stay at the crease as he settled in. He needed AB de Villiers to usher him through the period where even singles were hard to come by and soon realised patience would pay off.
Only at the very end, when Perera and Malinga seemed to have dinner rather than death bowling on their minds, did Miller pounce on anything too full and one which was too short. Miller registered the first South African half-century on the tour after their top order failed - Hashim Amla's absence is growing glaring as each match goes by.
South Africa tried a third opening pair in as many matches with Lions' team-mates Alviro Petersen and Quinton de Kock fronting up first. Both were watchful but de Kock was unable to contain his attacking instincts and was vulnerable outside the offstump.
He offered a chance in the fourth over when he swung at a wide one without any foot movement but Tillakaratne Dilshan at slip could not hold on. Sri Lanka hit back two balls later when Malinga bowled his first short ball and Petersen tried to hook too early, only to glove it to Kumar Sangakkara.
Sri Lanka's attack continued to find the edge of de Kock's bat and the youngster fell on his sword to open South Africa's middle up to a familiar state of panic. Both JP Duminy and Faf du Plessis posted insubstantial scores, with Duminy looking good again but unable to kick on and du Plessis uneasy at the crease and almost run out twice before actually being found short of his ground.
De Villiers looked closer to breaking the lean run but Sri Lanka's spinners and Ajanthan Mendis in particular did not let him get away. Mendis was difficult to pick while Rangana Herath and Dilshan kept things tight. It was only when Miller decided to hit out that the complexion of South Africa's tour became a little rosier.
Things got better for them from there as the fit-again Lonwabo Tsotsobe did the bulk of the damage upfront. He plucked three wickets in a six-over spell in which he extracted bounce, produced seam movement and partnered Morne Morkel to perfection.
Morkel created pressure at his end with pace and steep lift, while Tsotsobe's accuracy ensured eight dot balls were produced before the first run was scored. Sri Lanka's were troubled by anything back of a length and Dilshan was the first to succumb. He spooned a catch to de Villiers at cover before Kumar Sangakkara went in the same over, chasing one that moved away.
Upul Tharanga was also undone by bounce and edged Tsotsobe to Petersen at slip. With Sri Lanka at 16 for 3, South Africa were in control for the first time in the series.
They held the match in their grip even as Mahela Jayawardene and Dinesh Chandimal combined for a 55-run stand. Robin Peterson reviewed an lbw shout against Jayawardene, which was going down leg and Jayawardene survived a stumping chance when Peterson was bowling but the left-arm spinner had the last laugh. Peterson bowled Jayawardene with one that skidded on, but that was the end of his involvement in the night.
Peterson's figures were ruined by Perera, who hit his first four sixes over the mid-wicket boundary. Then, he sent Peterson back over his head for four and he finished with the biggest hit of the night, over square leg.
That over brought Sri Lanka's required run-rate below six but, it would take more than one over to change the course of the match. Perera had a few more meaty hits, but he didn't have a second over to match his first and when he was dismissed, Sri Lanka's hopes went with him.
Firdose Moonda is ESPNcricinfo's South Africa correspondent