Sri Lanka 306 for 7 in 39 overs (Shanaka 65, Thisara 51*, Duminy 2-35) beat South Africa 187 for 9 in 21 overs (Amla 40, Duminy 38, Lakmal 3-46) by three runs (DLS method)
Suranga Lakmal defended seven runs off the final over to cap off Sri Lanka's most inspired showing in the field and best batting performance of the series so far and end an 11-match losing streak against South Africa.
After rain interrupted both innings, South Africa's target was reduced to 191 runs off 21 overs and they looked set to reach it. They needed 69 runs off the last 10 overs with seven wickets in hand when Sri Lanka started a squeeze which became a strangle. South Africa lost six wickets for 54 runs as Thisara Perera and Lakmal took Sri Lanka to their first win in the five-match series.
Sri Lanka created a position of strength for themselves from the start of the match. Upul Tharanga and Niroshan Dickwella put on their first opening partnership over 50 in the series, Kusal Perera scored a quickfire half-century, Thisara added a fifty of his own and Dasun Shanaka, playing his 10th ODI and first since November 2016, top-scored with 65 off 34 balls.
The only South African bowler who was somewhat spared was the most experienced. JP Duminy was the only member of the attack who conceded at under six runs to the over as the inexperience of the rest of the pack, who were without Kagiso Rabada, showed.
Sri Lanka, on the other hand, will take confidence from their much-improved efforts albeit against a South African XI missing many of its regulars. The depth of the South African attack was tested throughout Sri Lanka's time at the crease and the young seamers struggled with consistency of length and line in damp conditions.
Dickwella took advantage as soon as Lungi Ngidi went too full and was particularly severe on debutant Junior Dala, off whom he took three fours in the eighth over. Duminy, who was introduced in the 10th over, ended the opening stand when Dickwella got a leading edge trying to paddle him past Quinton de Kock but that did little to stop the runs. Tharanga took over from where Dickwella left off and sent Andile Phehlukwayo for back-to-back fours and Wiaan Mulder for a six over long-off. Mulder had the last laugh in that situation when he bowled Tharanga with an offcutter but his yo-yo outing saw him finish as South Africa's most expensive bowler.
Keshav Maharaj made his first appearance in the series and had Kusal Mendis lbw with the score on 100 but then Sri Lanka wrested control. Kusal Perera and Angelo Mathews put on 59 runs for the fourth wicket, and both fell to rash shots. Mathews threw his bat at a delivery outside off, got a thick outside edge and de Kock flung himself to his right to pluck the ball out of the air while Kusal Perera, after bringing up fifty off 28 balls, holed out to long-on.
That left Thisara to launch the late assault and he did not disappoint, though he was overshadowed by his junior partner. Shanaka's first shot in anger was a slog-sweep over midwicket off Duminy and he then thumped Mulder over mid-off, sent an Andile Phehlukwayo slower ball over midwicket, hoicked Dala off his hips and then took 21 runs off Dala's final over to bring up fifty off 30 balls. By then, Thisara had joined in on the fun too and almost took Ngidi's hand off as he slammed the ball past him for four, smoked him for six over midwicket and found six more over Ngidi's head. Thisara's fifty came off 44 balls.
Sri Lanka scored 105 runs in the last ten overs to finish on 306 and South Africa's target was revised to 308 runs in 39 overs at an asking rate of 7.9, which then became even tougher when the rain returned after two overs of the reply. South Africa were 21 without loss and were off the field for an hour and a quarter. When they returned, they had to score 170 runs from the remaining 19 overs, at an asking rate of 10.50.
De Kock, in his first match as captain, grabbed the chase by the scruff of the neck and was on 23 off 12 balls when he was bowled by a Lakmal full-toss as he tried to cut. Reeza Hendricks, the centurion from the third match, drove Shanaka to cover, where Dhananjaya de Silva needed a second attempt at the catch, so it was up to Hashim Amla to steady things.
Amla's fluency returned and with Duminy at the other end, the boundary was plundered often. The pair put on 57 for the third wicket and had South Africa on track. But when Amla was dismissed, slicing an Akila Dananjaya ball to point, Sri Lanka started to claw their way back.
Mathews took a low catch at extra cover to dismiss Heinrich Klaasen and Duminy was run-out by a Shanaka direct-hit at the non-striker's end in the same over, leaving the crowd clearing their throats as South Africa stumbled. They were 130 for 5 after 13 overs, needing 61 runs from 48 balls. Phehlukwayo slammed two fours off Lahiru Kumara but was bowled by Thisara while playing across the line, and Mulder was caught off a pull shot by Dhananjaya at short midwicket which left David Miller with Keshav Maharaj and the tail.
Miller needed to keep strike, with Maharaj's penchant to swing wildly, and the balance between run-scoring and run-refusal was delicate. Maharaj got lucky with an inside egde off Lakmal past the keeper and showed some measure of his batting ability when he struck Thirsara back over his head for four but missed an attempt to slap him through cover again and was bowled. At that stage, South Africa needed eight off the final over and when Miller tried to go big off the second ball, a well-disguised slower delivery, he played on to end South Africa's challenge.