Starting the penultimate day of the match with a slender lead of seven runs, Sri Lanka lost just a single wicket during the entire day to reach 420 for five at stumps, a second-innings lead of 241 runs.
The wicket of Dinesh Chandimal (89) was the lone success for the Pakistan bowlers as their hard work proved futile on an unresponsive surface.
Left-arm seamer Junaid Khan, who took five wickets in the first innings, picked up his third scalp in the second when Chandimal hooked him straight to Rahat Ali at deep fine leg.
Chandimal, unbeaten on 24 overnight, added 138 runs for the fifth wicket with captain Mathews and put paid to Pakistan's hopes of making early inroads.
Mathews, who hit 12 fours and a six on his way to his second Test hundred, then added 96 for the unbroken sixth wicket with wicketkeeper Prasanna Jayawardene (48 not out) to deny Pakistan any further success.
Ace off-spinner Saeed Ajmal was wicketless after sending down 42 overs in the second innings and his lack of success on a fourth-day pitch underlined the misery for the Pakistan bowlers.
There was more heartbreak for Pakistan on Friday as they lost wicket-keeper Adnan Akmal for the remainder of the series due to a fracture in his left-hand index finger.
First-innings top-scorer Younus Khan took over the gloves for Pakistan during the day's play.
Scorecard
Sri Lanka (1st innings): 204
Pakistan (1st innings): 383
Sri Lanka (2nd innings): (overnight 186-4)
D. Karunaratne b Junaid 24
K. Silva c Akmal b Junaid 81
K. Sangakkara c Younus b Bhatti 55
M. Jayawardene c Shafiq b Bhatti 0
D. Chandimal c Rahat b Junaid 89
A. Mathews not out 116
P. Jayawardene not out 48
Extras: (lb-7) 7
Total: (for five wickets, 148 overs) 420
To bat: S. Senanayake, R. Herath, S. Eranga, S. Lakmal
Fall of wickets: 1-47, 2-146, 3-150, 4-186, 5-324
Bowling: Junaid 31-2-81-3, Rahat 33-8-82-0, Bhatti 33-8-131-2, Ajmal 42-10-96-0, Hafeez 9-1-23-0
Image: Angelo Mathews
Photograph: Getty Images
Bhatti and Junaid bowl Pakistan into strong position
Pakistan's Junaid, Bhatti restrict Sri Lanka to 204
Injured Pakistan 'keeper Adnan Akmal out of SL Tests
'At the UN, there were times I wished India had a stronger govt'
Sri Lanka recall Jayawardene, Herath for Pakistan Tests