KANDY - 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.

Scoreboard

Sri Lanka :

Niroshan Dickwella c de Kock b Duminy 34

Upul Tharanga b Mulder 36

Kusal Mendis lbw b Maharaj 14

Kusal Perera c Miller b Duminy 51

Angelo Mathews c de Kock b Ngidi 22

Dhananjaya de Silva c Dala b Ngidi 10

Thisara Perera not out 51

Dasun Shanaka c Mulder b Phehlukwayo 65

Akila Dananjaya not out 1

EXTRAS: (lb9, w12, nb1) 22

TOTAL: (7 wkts, 39 overs) 306

FOW: 1-61, 2-92, 3-100, 4-159, 5-183, 6-195, 7-304

BOWLING: Ngidi 8-0-65-2, Dala 8-0-64-0, Phehlukwayo 6-0-45-1, Duminy 6-0-35-2, Mulder 6-0-51-1, Maharaj 5-0-37-1

SOUTH AFRICA:

Quinton de Kock b Lakmal 23

Hashim Amla c Kumara b Dananjaya 40

Reeza Hendricks c D. de Silva b Shanaka 2

Jean-Paul Duminy run out 38

Heinrich Klaasen c Mathews b D. de Silva 17

David Miller b Lakmal 21

Andile Phehlukwayo b T Perera 9

Willem Mulder c D de Silva b Lakmal 4

Keshav Maharaj b T Perera 17

Junior Dala not out 3

Lungi Ngidi not out 1

EXTRAS: (lb5, w6, nb1) 12

TOTAL: (9 wkts, 21 overs) 187

FOW: 34-1, 51-2, 108-3, 129-4, 130-5, 149-6, 155-7, 183-8, 183-9

BOWLING: Lakmal 5 0 46 3, Dananjaya 3 0 30 1, T. Perera 4 0 32 2, Shanaka 2 0 20 1, Kumara 3 0 28 0, D. de Silva 4 0 26 1

TOSS: South Africa

UMPIRES: Paul Reiffel (AUS), Lyndon Edward Hannibal (SRI)

TV UMPIRE: Nigel Llong (ENG)

MATCH REFEREE: Javagal Srinath (IND)