The hosts, sent in to bat after Pakistan captain Misbah-ul Haq won the toss for the third time in a row, stuttered to 272-8 in their first innings by stumps on the opening day.
Left-handed Karunaratne anchored the innings with a dogged 130, his second Test century following the 152 against New Zealand in Christchurch last December.
Yasir ended the day with four for 77, taking his tally in the series to 21 wickets, the most by a Pakistani bowler in a three-Test rubber in Sri Lanka.
The series is locked 1-1 after Pakistan won the first Test by 10 wickets and Sri Lanka responded with a seven-wicket victory in the second match.
Also Read
Pakistan secured an early break with the wicket of Kaushal Silva, who had scored 125 in Galle and 80 in Colombo.
This time Silva made nine when he was caught behind off left-arm seamer Rahat Ali, who was picked alongside Ehsan Ali and Imran Khan in a new-look pace attack for the decider.
Tharanga, who replaced Kumar Sangakkara for the match, made 46 when he edged Yasir to slip where an alert Younis Khan took a smart catch diving in front.
Lahiru Thirimanne (11) and skipper Angelo Mathews (three) fell in successive overs from Yasir to mistimed drives as Sri Lanka slipped to 137-4.