Mohammad Hafeez chipped in with 70 as the tourists surpassed Sri Lanka's 256-9 in the 41st over at the Premadasa stadium to take a decisive 3-1 lead in the series.
The series win kept Azhar Ali's Pakistan in contention for a place in the eight-nation Champions Trophy in England in 2017.
Pakistan are two points ahead of the West Indies at number eight in the rankings, but both teams are due to play a tri-series in Zimbabwe next month that will determine the final spot.
Pakistan's one-day success follows their 2-1 victory over Sri Lanka in the preceding Test series under Misbah-ul Haq's captaincy.
Sri Lanka are assured of taking part in the Champions Trophy, but their lacklustre display did not do justice to the former world champions.
Shehzad and Azhar put Pakistan on the road to victory with an opening stand of 75 in 11 overs before the skipper was removed by sling-arm fast bowler Lasith Malinga for 33.
Hafeez helped Shehzad build on the fine start by adding 115 for the second wicket, but Sri Lanka hit back to remove both batsmen in the space of 23 runs.
Shehzad fell five runs short of his fourth one-day century when he cut seamer Suranga Lakmal to a diving Kusal Perera at third man. He hit 12 boundaries and a six.
Hafeez was caught behind by Dinesh Chandimal off spinner Milinda Siriwardana to leave Pakistan on 213-3, but Sri Lanka's recovery came too late.
Shoaib Malik hit a 16-ball 29 and ended the match by lofting Siriwardana over mid-wicket for his fourth six. Sarfraz Ahmed remained unbeaten on 17.
Earlier, Lahiru Thirimanne top-scored with 90 for Sri Lanka after skipper Angelo Mathews won the toss for the first time on Pakistan's current tour and elected to bat.
The left-hander put on 109 for the second wicket with Tillakaratne Dilshan (50) after Perera had been dismissed by Mohammad Irfan off the second ball of the match.
Thirimanne missed his fifth one-day century when he swept leg-spinner Yasir Shah to deep square-leg, where Shehzad picked up a low catch to make amends for a dropped catch in the bowler's previous over.
Besides Thirimanne and Dilshan, none of the other top-order batsmen settled in as Mathews fell for 12 and Dinesh Chandimal was dismissed after making 20.
Tailender Malinga smashed 17 off 13 balls at the end to ensure Sri Lanka crossed the 250-run mark.
Irfan finished with three wickets, while fellow seamer Anwar Ali took two.
Scorecard
Sri Lanka:
K. Perera c Imad b Irfan 0
T. Dilshan b Imad 50
L. Thirimanne c Shehzad b Yasir 90
A. Mathews c Yasir b Rahat 12
D. Chandimal c Yasir b Irfan 20
A. Priyanjan c Hafeez b Anwar 18
M. Siriwardana c Rizwan b Anwar 19
S. Pathirana run out 14
L. Malinga c Rizwan b Irfan 17
S. Lakmal not out 1
N. Pradeep not out 0
Extras: (b4, lb1, w8, nb2) 15
Total (for nine wickets, 50 overs) 256
Fall of wickets: 1-0 (Perera), 2-109 (Dilshan), 3-143 (Mathews), 4-170 (Chandimal), 5-186 (Thirimanne), 6-215 (Siriwardana), 7-228 (Priyanjan), 8-243 (Pathirana), 9-252 (Malinga)
Bowling: Irfan 10-0-50-3 (nb2, w2), Anwar 7-0-41-2 (w4), Rahat 7-0-39-1 (w2), Yasir 10-0-50-1, Azhar 2-0-13-0, Imad 10-0-43-1, Malik 4-0-15-0.
Pakistan:
Azhar Ali c sub (Senanayake) b Malinga 33
Ahmed Shehzad c Perera b Lakmal 95
Mohammad Hafeez c Chandimal b Siriwardana 70
Sarfraz Ahmed not out 17
Shoaib Malik not out 29
Extras: (b4, w9) 13
Total (for three wickets, 40.5 overs) 257
Fall of wickets: 1-75 (Azhar), 2-190 (Shehzad), 3-213 (Hafeez)
Bowling: Malinga 9-2-46-1, Lakmal 8-0-50-1 (w3), Pathirana 10-0-81-0, Pradeep 2.2-0-9-0 (w1), Mathews 2.4-0-9-0 (w2), Siriwardana 5.5-0-28-1, Dilshan 3-0-30-0 (w3).
Image: Ahmed Shehzad
Photograph: Dinuka Liyanawatte/Reuters