Angelo Mathews kept a cool head to guide Sri Lanka to a nerve-jangling two-wicket win over Pakistan in the fifth and final one-day international on Monday.
Chasing 248 for victory, Sri Lanka reached their target with two balls to spare to take the five-match series 3-1. One game was ruined by bad weather.
Mathews, who arrived at the crease with the total 97 for four in the 25th over, hammered an unbeaten 80 off 76 balls with two sixes and four fours and claimed the man of the match award.
Nuwan Kulasekara offered good support, making 10 not out in an unbroken ninth-wicket stand of 36 in 20 deliveries.
Sri Lanka began the final over needing 15 runs for victory and paceman Mohammad Sami started it with a wide.
Mathews scored 10 off the next three balls and punched the fourth over point for four to settle the issue.
Sami, back after missing the previous two games due to a sore thumb, was the most expensive bowler as he conceded 75 runs in 9.4 overs without taking a wicket.
Leg-spinner Shahid Afridi seemed to put Pakistan in charge when he removed Kumar Sangakkara and Mahela Jayawardene off successive balls in the 25th over.
Sangakkara was stumped by wicketkeeper Sarfraz Ahmed for 40 and Jayawardene fell first ball when he offered a tame return catch.
Earlier, Pakistan opening batsman Imran Farhat marked his first match of the series by hitting 56 before Azhar Ali (30), Asad Shafiq (38) and Misbah-ul-Haq (32) kept the momentum going.
They all batted around Umar Akmal who top-scored with an unbeaten 55 off 61 balls containing two sixes and five fours.
The two teams next play a series of three tests beginning on Friday in Galle.
Imran Farhat c Chandimal b Perera 56
Mohammad Hafeez b Kulasekara 6
Azhar Ali c Thirimanne b Mendis 30
Asad Shafiq run out 38
Misbah-ul-Haq c Perera b Mendis 32
Umar Akmal not out 55
Shahid Afridi c Jayawardene b Kulasekara 9
Sohail Tanvir c Tharanga b Malinga 11
Umar Gul not out 2
Extras (b2, lb3, w3) 8
Total (for seven wickets; 50 overs) 247
Fall of wickets: 1-22 (Hafeez), 2-82 (Farhat), 3-113 (Ali), 4-146 (Shafiq), 5-207 (Misbah), 6-229 (Afridi), 7-244 (Tanvir)
Bowling: Malinga 10-1-52-1 (w1), Kulasekara 10-1-53-2, Mathews 10-0-41-0, Dilshan 3-0-12-0, Perera 8-0-54-1 (w1), Mendis 9-0-30-2 (w1).
U. Tharanga b Tanvir 2
T. Dilshan b Tanvir 10
K. Sangakkara st Ahmed b Afridi 40
D. Chandimal c Sami b Hafeez 54
M. Jayawardene c and b Afridi 0
A. Mathews not out 80
T. Perera run out 0
L. Thirimanne run out 11
J. Mendis c Shafiq b Tanvir 19
N. Kulasekara not out 10
Extras (lb10, w12) 22
Total (for eight wickets; 49.4 overs) 248
Fall of wickets: 1-18 (Dilshan), 2-19 (Tharanga), 3-97 (Sangakkara), 4-97 (Jayawardene), 5-135 (Chandimal), 6-138 (Perera), 7-175 (Thirimanne), 8-212 (Mendis).
Bowling: Gul 10-1-43-0, Tanvir 10-0-42-3 (w7), Hafeez 10-0-30-1, Sami 9.4-0-75-0 (w2), Afridi 10-0-48-2 (w3).
Result: Sri Lanka win by two wickets to clinch five-match series 3-1
Umpires: Ranmore Martinesz (SRI) and Paul Reiffel (AUS)
TV umpire: Ruchira Palliyaguruge (SRI)
Match referee: Chris Broad (ENG)