Shoaib Maqsood and Fawwad Alam had drifted the match in favour of Pakistan that going to the other way when visitors were 5 down for 106 in the 23rd over.
Chasing 276, Pakistan’s top order got fumbled a bit. Sri Lankan skipper Angelo Matthews struck twice dismissing Mohammad Hafeez (21) and Younis Khan (3).
Umar Akmal(15) and Misbah-ul-Haq(13) went back early. Ahmed Shahzad took 61 balls to score 49 runs but got bowled out off Thisara Parera.
Maqsood scored unbeaten 89 off 73 balls hitting 9 fours. He blunted Lasith Malinga’s yorkers, he had a life off Rangana Herath and capitalised on it with some powerful bottom-handed flicks and whips while Alam made 62 off 61 balls.
Shahid Afridi, who scores 14 runs, played the winning shot that went to the boundary when Pakistan needed 2 runs in two balls.
Earlier, Sri Lanka batting first were 75 for 4 in the 18th over but Angelo Mathews brought up his highest ODI score 89, without quite managing to bring up that elusive century, but he did more than enough for the recovery of his team from a shaky start to post a total of 275 in a match reduced to 45 overs a side.
Mathews and Mahela Jayawardene put on 116 for the fifth wicket, before a merry thrash in the late overs brought 60 runs from the last five and 105 from the last 10. Ashan Priyanjan, moving away from his stumps to make room or shuffling across them to whip balls from outside off, breezed away to an unbeaten 15-ball 39, and took 17 from the final over to leave Junaid Khan nursing figures of 0 for 75 in nine overs.
Mohammad Irfan making come back to international cricket after November 2013 bowled impressive 9-over spell, took 2 wickets and conceded 48 runs. Wahab Riaz dismissed three batsmen giving away 50 runs.