Pakistan had Sri Lanka in trouble at 186-4 on the third day when fast bowler Bilawal Bhatti claimed key wickets of experienced Kumar Sangakkara (55) and Mahela Jayawardene in quick succession, and Junaid Khan had opening batsman Kaushal Silva (81) caught behind.
But Pakistan pacers struggled to get through to the defenses of Chandimal and Mathews and even the second new ball didn't bring them any success in an extended 2½ -hour first session due to Friday prayers.
Chandimal hit eight boundaries and faced 124 balls, while Mathews' 125-ball innings contained six boundaries and a six over mid-on off Saeed Ajmal.
Both batsmen showed a lot of grit against the Pakistan pace trio of Khan, Bhatti and Rahat Ali while offspinner Ajmal also couldn't find much turn to bother batsmen.
Just before play started, Pakistan wicketkeeper Adnan Akmal was ruled out of the remainder of the test series after fracturing his index finger.
Akmal was hit on his left index finger when he caught Silva in the last over of the third day on Thursday.
The Pakistan Cricket Board said in a statement on Friday that Sarfraz Ahmed will be flown in for the remaining two matches in the series.
Ahmed played in last year's three-test series in South Africa before Akmal regained his place in the national team.
Younis Khan replaced Akmal behind the wickets when play resumed on the fourth day.