Pakistan must score 271 to ruin Jayawardene's farewell
Pakistan bowler Wahab Riaz (2L) celebrates with his teammates after he dismissed Sri Lankan batsman Niroshan Dickwella during the fourth day of the second Test in Colombo on August 17, 2014 - by Lakruwan Wanniarachchi
The hosts, trailing by 12 runs on the first innings, were bowled out for 282 in their second knock just before tea on the fourth day in Colombo.
Skipper Angelo Mathews remained unbeaten on 43. Seamer Wahab Riaz and off-spinner Saeed Ajmal claimed three wickets each for Pakistan.
Earlier, Jayawardene was dismissed for 54 in his last Test innings, in front of 4,000 home fans at the Sinhalese Sports Club.
The overnight pair of Jayawardene and his long-time team-mate Kumar Sangakkara, batting together for the last time in a Test match, took their partnership to 107 after Sri Lanka resumed the day on 177-2.
But both batsmen fell to Ajmal within three runs of each other as the hosts slipped to 189-4 within the first 30 minutes of play.
Ajmal had the left-handed Sangakkara caught at silly point by Azhar Ali for 59 and then removed Jayawardene in his next over after the batsman had added five runs to his overnight 49.
Jayawardene mistimed a lofted shot to mid-wicket where Ahmed Shehzad took a low tumbling catch.
One run earlier, Jayawardene had survived an appeal for a catch off Riaz as replays showed the ball touch the ground before landing in wicket-keeper Sarfraz Ahmed's gloves.
The 37-year-old Jayawardene is one of only five batsmen to score more than 11,000 runs in both Test and one-day cricket -- the others being Sachin Tendulkar, Ricky Ponting, Jacques Kallis and team-mate Kumar Sangakkara.
The Pakistani fielders applauded as the crowd gave the departing Jayawardene a standing ovation. The batsmen raised his bat to acknowledge the cheers before walking off.
The 149-Test veteran, who made his debut 17 years ago, finished with 11,814 runs at an average of 49.84 with 34 hundreds and 50 half-centuries.
Jayawardene began his last Test with an average of 50.02, but it dropped below the 50-mark after he was dismissed for four and 54 in the match.
His 2,921 runs in 27 Tests at the SSC are the most by any batsman at a single ground. He averaged 74.89 at the SSC with 11 centuries.
Having retired from Twenty20 internationals after Sri Lanka's title-winning campaign in the World T20 in April, Jayawardene will now play only one-day cricket heading into next year's World Cup Down Under.
Pakistan missed left-arm seamer Junaid Khan, who did not bowl in Sri Lanka's second innings after being hit on the helmet by a rising ball from Dhammika Prasad on Saturday. He was kept under observation at a hospital for a few hours.
Team manager Moin Khan said Junaid may bat if needed.
Sri Lanka won the first Test in Galle by seven wickets.