Afridi's (3-37) mid-innings spell of quick leg breaks grabbed the initiative for the Pakistan on a slow pitch, claiming the wickets of Kumar Sangakkara (22), Kashal Lokuarchchi (13) and Russel Arnold (nought).
Sri Lanka, who were put into bat in the morning, had started their innings well with Upul Tharanga (23) and Chamara Kapugedera (50) sharing a 57-run opening stand.
Medium pacer Abdul Razzaq made the first breakthrough when Tharanga slashed at a wide delivery and was caught behind, allowing wicketkeeper Kamran Akmal an opportunity to make amends from a dropped chance a few minutes before.
The 18-year-old Kapugedera grabbed an opportunity to impress with a maiden ODI fifty having been asked to stand-in as an opener in the absence of the injured Marvan Atapattu (back) and Sanath Jayasuriya (thigh).
However, Kapugedera was one of two top order batsmen run out by Younis Khan when he was sent back late by Sangakkara having tried to pinch a quick single.
Khan also dismissed Sri Lanka captain Mahela Jayawardene, who had been anchoring the middle order with 31 from 56 balls, with a direct hit from cover.
Jayawardene's departure left Sri Lanka in deep trouble on 156-6 but Tillakaratne Dilshan lifted the hosts past the 200-mark with and enterprising 44 from 46 balls.
Dilshan added 37 with Farveez Maharoof (19) and other 23 with Dhammika Prasad before being bowled in the penultimate over while attempting an ambitious reverse sweep.
Fast bowler Rana Naveed-ul-Hasan (2-40) finished off the innings with two wickets in the final over.
Pakistan lead the three-match series 1-0 following a tense victory in a low-scoring match on Sunday.
The opening match was abandoned after heavy rain.