Having been bowled out for 278 in the first innings, Sri Lanka hit back to reduce Pakistan to 209-9 by stumps on the second day that saw 11 wickets fall on the evenly-paced pitch.
Nuwan Pradeep grabbed 3-26 in 14 steady overs and fellow seamer Dhammika Prasad chipped in another three wickets to cause a dramatic Pakistani collapse.
Sarfraz Ahmed returned unbeaten on a gallant 72 and Azhar Ali made 52, but none of the other batsmen settled down to form a sizeable partnership.
Pakistan were struggling at 152-7 when Yasir helped Sarfraz add 45 for the eighth wicket, himself contributing 18 with the bat to follow his impressive bowling.
Also Read
Yasir claimed another five-wicket haul as Sri Lanka added six runs to their overnight score of 272-8 before they were dismissed within 20 minutes of the start.
Tharindu Kaushal was leg-before to left-arm seamer Rahat Ali for 18 and last man Pradeep fell in the same fashion to Yasir without scoring.
Yasir had taken 2-79 and 7-76 in the first Test in Galle to fashion Pakistan's 10-wicket win. He then claimed 6-96 and 2-55 in the second match in Colombo which Sri Lanka won by seven wickets.
The 29-year-old, who hails from the Khyber region of northwest Pakistan, has already grabbed 59 wickets in a 10-Test career which began in October last year.
Pakistan lost both openers, Shan Masood and Ahmed Shehzad, by the score of 40 and star batsman Younis Khan was run out off the last ball of the morning session to make it 45-3.