Chasing Pakistan’s challenging 287-8, the hosts recovered from 159-5 to post 288-8 with 11 balls to spare in the day-night match.
Earlier, Pakistan captain Azhar Ali won the toss and chose to bat first.
Azhar Ali, Mohammad Rizwan and Shoaib Malik all scored 50s in the innings.
The Pakistani skipper was the top scorer for the team with 79 runs from 104 balls followed by Mohammad Rizwan with 52 runs from 38 balls.
Shoaib Malik scored 51 runs from 51 balls while Ahmed Shehzad made 30 runs from 43 balls.
Debutant Sachith Pathirana and Lasith Malinga took two wickets each while Angelo Mathews, Nuwan Pradeep, Milinda Siriwardana and Tillakaratne Dilshan all grabbed one wicket as well.
The third match will be played in Colombo on Sunday.
Full scoreboard of the second one-day international between Pakistan and Sri Lanka in Pallekele on Wednesday:
Azhar Ali c Siriwardana b Dilshan 79
Ahmed Shehzad b Pathirana 30
Mohammad Hafeez c Mathews b Pathirana 9
Babar Azam b Siriwardana 12
Shoaib Malik b Mathews 51
Mohammad Rizwan lbw b Pradeep 52
Sarfraz Ahmed lbw b Malinga 7
Anwar Ali not out 29
Yasir Shah c Siriwardana b Malinga 1
Rahat Ali not out 0
Extras: (b4, lb3, w9, nb1) 17
Total (for eight wickets, 50 overs) 287
Fall of wickets: 1-59 (Shehzad), 2-75 (Hafeez), 3-96 (Azam), 4-179 (Malik), 5-197 (Azhar), 6-217 (Sarfraz), 7-273 (Rizwan), 8-278 (Yasir).
Bowling: Mathews 10-2-36-1, Pradeep 8-1-42-1, T. Perera 2-0-15-0 (w1), Malinga 10-0-64-2 (nb1, w5), Pathirana 9-0-70-2, Siriwardana 5-0-22-1 (w2), Dilshan 6-0-31-1 (w1)
K. Perera c Yasir b Irfan 68
T. Dilshan b Rahat 47
U. Tharanga b Rahat 28
A. Mathews run out 8
L. Thirimanne c Anwar b Rahat 4
D. Chandimal not out 48
M. Siriwardana lbw b Hafeez 26
S. Pathirana st Sarfraz b Hafeez 33
T. Perera c Malik b Anwar 15
L. Malinga not out 2
Extras: (lb2, w7) 9
Total (for eight wickets, 48.1 overs) 288
Fall of wickets: 1-92 (K. Perera), 2-140 (Tharanga), 3-155 (Dilshan), 4-157 (Mathews), 5-159 (Thirimanne), 6-196 (Siriwardana), 7-248 (Pathirana), 8-285 (T. Perera).
Bowling: Irfan 10-0-61-1 (w2), Rahat 9.1-0-73-3 (w3), Hafeez 10-0-61-2 (w1), Anwar 7-0-33-1, Yasir 10-0-51-0 (w1), Malik 2-0-7-0.
Sri Lanka won by two wickets; level five-match series 1-1.
Umpires: Ranmore Martinesz (SRI) and Rod Tucker (AUS)
TV umpire: Ian Gould (ENG)
Match referee: Javagal Srinath (IND)
Sri Lanka innings
Sri Lanka chases target in 48.1 overs winning second ODI by 2 wickets(with 11 balls remaining.
After 45 Overs
Sri Lanka 275/7 (13 runs required from 30 balls, RR: 6.11, RRR: 2.60)
NLTC Perera 12
LD Chandimal 41
After 40 Overs
Sri Lanka 252/7 (36 runs required from 60 balls, RR: 6.30, RRR: 3.60)
LD Chandimal 27
NLTC Perera 3
After 35 Overs
Sri Lanka 207/6 (81 runs required from 15 overs, RR: 5.91, RRR: 5.40)
LD Chandimal 16
SS Pathirana 4
After 30 Overs
Sri Lanka 189/5 (99 runs required from 20 overs, RR: 6.30, RRR: 4.95)
TAM Siriwardana 23
LD Chandimal 6
After 25 Overs
Sri Lanka 166/5 (122 runs required from 25 overs, RR: 6.64, RRR: 4.88)
After 20 Overs
Sri Lanka 147/2 (141 runs required from 30 overs, RR: 7.35, RRR: 4.70)
AD Mathews 3
TM Dilshan 44
After 16 Over
Sri Lanka 130/1 (158 runs required from 34 overs, RR: 8.12, RRR: 4.64)
TM Dilshan 38*
WU Tharanga 20*
End of over 11: Sri Lanka 102/1 (Require 186 runs to win)
End of over 10: Sri Lanka 98/1 (Require 190 runs to win)
Pakistan were at 44/0 at this stage of their innings
End of over 9: Sri Lanka 94/1 (Require 194 runs to win)
Mohammad Irfan grabs the wicket of dangerous Parera in his second spell.
WICKET: Kausal Parera c Yasir Shah b Mohammad Irfan 68 (25). Sri Lanka 92/1
End of over 8: Sri Lanka 91/0 (Require 197 runs to win)
Pakistan has to grab couple of wickets if they are to stay alive in this match.
End of over 7: Sri Lanka 86/0 (Require 202 runs to win)
Pakistani bowling looking all over the place at the moment.
End of over 6: Sri Lanka 74/0 (Require 214 runs to win)
Anwar Ali introduced into the attack and gives away nine runs in the over.
End of over 5: Sri Lanka 65/0 (Require 223 runs to win)
Mohammad Hafeez bowled the fifth over and gave away 11 runs in the over.
Kausal Parera raises his bat for a fifty.
End of over 4: Sri Lanka 54/0 (Require 234 runs to win)
Rahat Ali conceding more than 10 runs in his every over.
Parera and Dilshan have put up a 50 run stand.
End of over 3: Sri Lanka 41/0 (Require 247 runs to win)
Kausal Parera looks like a man who has been sent out on a mission.
End of over 2: Sri Lanka 27/0 (Require 261 runs to win)
Sri Lankan openers scoring boundaries early on in the run chase. Rahat Ali concedes 18 runs in his opening over.
End of over 1: Sri Lanka 9/0 (Require 279 runs to win)
Not the start Pakistan would have wanted as Mohammad Irfan goes expensive in the first over.
End of over 50: Pakistan 287/8 (RR: 5.67 per over)
WICKET: Yasir Shah c Milinda Siriwardana b Lasith Malinga 1 (2). Pakistan 278/8
End of over 49: Pakistan 278/7 (RR: 5.67 per over)
Sri Lanka dismiss Mohammad Rizwan in the over but concede eight runs in the over as well.
WICKET: Mohammad Rizwan lbw Nuwan Pradeep 52 (38). Pakistan 273/7
End of over 48: Pakistan 270/6 (RR: 5.62 per over)
Mohammad Rizwan keeping the scoreboard ticking with some late hitting
That’s a fifty for Mohammad Rizwan
End of over 47: Pakistan 263/6 (RR: 5.59 per over)
Mohammad Rizwan taking Malinga to the cleaners.
End of over 46: Pakistan 243/6 (RR: 5.28 per over)
Anwar Ali slogs Pathirana for a six.
End of over 45: Pakistan 233/6 (RR: 5.17 per over)
Malinga concedes seven runs in the over.
End of over 44: Pakistan 226/6 (RR: 5.13 per over)
Pakistan take five singles from the over.
End of over 43: Pakistan 221/6 (RR: 5.13 per over)
Malinga traps Sarfraz Ahmed leg before in the over.
WICKET: Sarfraz Ahmed lbw Lasith Malinga 7 (9). Pakistan 217/6
End of over 42: Pakistan 217/5 (RR: 5.16 per over)
End of over 41: Pakistan 208/5 (RR: 5.07 per over)
200 up for Pakistan. It can be said that Pakistan are not batting with the same consistency as the first ODI.
End of over 40: Pakistan 199/5 (RR: 4.97 per over)
The Sri Lankan team finally dismisses the Pakistani skipper in the over as Dilshan takes the wicket.
WICKET: Azhar Ali c Milinda Siriwardaba b Tillakaratne Dilshan 79 (104). Pakistan 197/5
End of over 39: Pakistan 195/4 (RR: 5.00 per over)
Five runs for Pakistan from Mathews over.
End of over 38: Pakistan 190/4 (RR: 5.00 per over)
This is the first time in the match that Pakistan’s scoring rate has reached five.
End of over 37: Pakistan 181/4 (RR: 4.89 per over)
Angelo Mathews removes Shoaib Malik who was looking to be dangerous for the hosts.
WICKET: Shoaib Malik b Angelo Mathews 51 (51). Pakistan 179/4
End of over 36: Pakistan 178/3 (RR: 4.94 per over)
Shoaib Malik reaches his 50 with a huge six over the midwicket area.
End of over 35: Pakistan 163/3 (RR: 4.65 per over)
Two boundaries scored on the square region by Shoaib Malik.
End of over 34: Pakistan 153/3 (RR: 4.39 per over)
Fifty run partnership scored by Azhar Ali and Shoaib Malik
End of over 33: Pakistan 145/3 (RR: 4.39 per over)
The visitor score just two runs from Malinga’s over.
End of over 32: Pakistan 143/3 (RR: 4.46 per over)
A productive over for the green shirts as 14 runs came from it.
End of over 31: Pakistan 129/3 (RR: per over)
Six runs conceded by Malinga in his fifth over.
End of over 30: Pakistan 123/3 (RR: 4.10 per over)
Azhar Ali raises his bat for a useful half century
End of over 29: Pakistan 116/3 (RR: 4.00 per over)
Shoaib Malik relying on singles to frustrate the Sri Lankan fielders. Malinga nearly caught out Azhar Ali as the ball fell short.
End of over 28: Pakistan 110/3 (RR: 3.92 per over)
Four runs for Pakistan in the over by Pathirana.
End of over 27: Pakistan 106/3 (RR: 3.92 per over)
A tight first over by Tillakaratne Dilshan.
End of over 26: Pakistan 105/3 (RR: 4.20 per over)
Five singles taken from the over.
End of over 25: Pakistan 100/3 (RR: 4.00 per over)
Pakistan take their total into triple figures.
End of over 24: Pakistan 96/3 (RR: 4.00 per over)
Milinda Siriwardana gets a wicket on his first delivery of the match.
WICKET: Babar Azam b Milinda Siriwardana 12 (19). Pakistan 96/3
End of over 23: Pakistan 96/2 (RR: 4.17 per over)
Malinga back into the attack now.
End of over 22: Pakistan 92/2 (RR: 4.18 per over)
A stumping chance missed by Dinesh Chandimal.
End of over 21: Pakistan 89/2 (RR: 4.23 per over)
Pakistan taking singles and scoring boundaries when the opportunity knocks.
End of over 20: Pakistan 86/2 (RR: 4.30 per over)
Babar Azam scored the boundary in the over.
End of over 19: Pakistan 78/2 (RR: 4.10 per over)
Pakistan take three runs from Parera’s over.
End of over 18: Pakistan 75/2 (RR: 4.16 per over)
Pathirana gets his second wicket as he dismisses Mohammad Hafeez.
WICKET: Mohammad Hafeez c Mathews b Pathirana 9 (15). Pakistan 75/2
End of over 17: Pakistan 74/1 (RR: 4.35 per over)
Pakistan take three singles from the 17th over.
End of over 16: Pakistan 71/1 (RR: 4.43 per over)
Mohammad Hafeez hit the first six of the match.
End of over 15: Pakistan 62/1 (RR: 4.13 per over)
Nuwan Pradeep was brought back into the attack and he gives away three singles in the over.
End of over 14: Pakistan 59/1 (RR: 4.21 per over)
Debutant Pathirana gets his first ODI wicket as he bowls Ahmed Shehzad, who had a wild swing at the left arm spinner.
WICKET: Ahmed Shehzad b Sachith Pathirana 30 (43). Pakistan 59/1
End of over 13: Pakistan 58/0 (RR: 4.46 per over)
Four runs came for Pakistan from Malinga’s second over.
End of over 12: Pakistan 54/0 (RR: 4.50 per over)
A fifty run opening between Mohammad Hafeez and Ahmed Shehzad.
End of over 11: Pakistan 49/0 (RR: 4.45 per over)
Lasith Malinga concedes five runs in his first over.
End of over 10: Pakistan 44/0 (RR: 4.40 per over)
Ahmed Shehzad gets into the act as he scores three boundaries in the over.
End of over 9: Pakistan 32/0 (RR: 3.55 per over)
Azhar Ali lofts Mathews over the midwicket for a boundary.
End of over 8: Pakistan 27/0 (RR: 3.37 per over)
Azhar scored the boundary in the over with a beautiful shot towards the midwicket area
End of over 7: Pakistan 22/0 (RR: 3.14 per over)
Mathews bowls his second maiden over.
End of over 6: Pakistan 22/0 (RR: 3.66 per over)
Shehzad survives a scare as Pradeep’s delivery just whizzes past his off stump. Meanwhile, Sri Lanka showing athleticism in the field. Their player making good dives to stop runs and boundaries.
End of over 5: Pakistan 16/0 (RR: 3.20 per over)
Pakistan take three singles in the over.
End of over 4: Pakistan 13/0 (RR: 3.25 per over)
Twelve runs conceded by Pradeep in his second over. The first boundary coming off a bye.
End of over 3: Pakistan 1/0 (RR: 0.33 per over)
A slow start by Pakistan in the innings. First run of the match scored.
End of over 2: Pakistan 0/0 (RR: 0.00 per over)
Nuwan Pradeep bowled the second over of the innings and bowls a maiden as well.
End of over 1: Pakistan 0/0 (RR: 0.00 per over)
Captain Angelo Mathews starts off by bowling a maiden over.
WE ARE READY FOR THE START OF PLAY
Ground staff are removing the covers now.
The showers have stopped now and the play might get underway soon. The ground is still covered though.
The match has been stopped due to rain. The ground has been covered.