Upul Tharanga hit 92 and fellow opener Kaushal Silva made 41, but Sri Lanka lost seven wickets on either side of the tea interval after coasting at 144-1.
Pakistan's two left-arm seamers Junaid Khan and Wahab Riaz toiled manfully under the hot sun to share seven wickets and lead a spirited display by the tourists seeking a series-levelling win.
Junaid ended the day with four for 69, including two wickets in the first over with the second new ball taken towards the end of the day's play. Riaz had three for 66.
Junaid said it was satisfying to restrict Sri Lanka on a pitch that gave the bowlers no assistance and credited team coach and former fast bowling great Waqar Younis for the success."For us seamers to take so many wickets on a dead wicket like this is fantastic," said the 24-year-old Junaid. "Hopefully we can wrap up the innings quickly and then the batsmen can get a big score.
"I don't think this would have been possible without the useful tips that Waqar Sir gave us. He is a legend and it always helps to learn from greats like him."
Sri Lanka's skipper Angelo Mathews made 39 when he was caught behind off Riaz for what became the last delivery of the day.
Tharanga put on 79 for the first wicket with Silva and 65 for the second with Kumar Sangakkara, but missed his century when he fell to a sharp catch by Azhar Ali at short-leg off Riaz.
"I don't think this was a very easy wicket to bat on," Tharanga said. "It was a bit two-paced and took more turn than what we are used to at this ground.
"300 is now our main target. We still have two wickets left and must get whatever runs we can. A good first innings total is important to get a favourable result in this game."
Standing ovation for Jayawardene
Sangakkara, who hit 221 in the first Test in Galle which Sri Lanka won by seven wickets, managed just 22 when he was bowled by a superb in-cutter from Riaz.
Pakistan's fielders lined up to greet Jayawardene, a 37-year-old veteran of 149 Tests, to the crease as firecrackers went off in the stands and some 3,000 home fans gave him a standing ovation.
But the star batsman, who was dropped by wicket-keeper Sarfraz Ahmed off Junaid just before tea, fell in the first over after resumption when he was trapped leg-before by Saeed Ajmal.
Ajmal, who will have his bowling action tested at the end of the month after being reported by the umpires in Galle, bowled 29 overs to take one for 67.
The SSC, which has been Jayawardene's home ground since his early days, was decorated with giant posters of the elegant batsman, many of them highlighting his career-best score of 374 at the same venue in 2006.
The Old Boys' Association of Nalanda College, where Jayawardene studied, set up a special stand at the ground for his classmates, current students and the college band.