Mathews closes on double century to frustrate Bangladesh
Stay tunned with 24 News HD Android App
Mathews was unbeaten on 178 with Vishwa Fernando alongside him on 17 after putting on 47 together in an unbroken ninth-wicket stand.
He shared 136 runs with fellow overnight batsman Dinesh Chandimal (66) before hosts Bangladesh had their first success of the day.
In the 24th over of the session, Chandimal attempted a premeditated reverse sweep but failed to make contact and was given out lbw, upheld on review.
Nayeem celebrated his third wicket of the innings and soon had a fourth when he bowled wicketkeeper-batsman Niroshan Dickwella, who made only three, four balls later.
Shakib took two wickets in two balls in the first over after the break to push Sri Lanka into a corner.
He first bowled Ramesh Mendis for one and then trapped Lasith Embuldeniya leg before for no score.
Mushfiqur Rahim dropped Fernando at mid-on on 16 to deny Shakib his fourth wicket.
Khaled Ahmed beat the Sri Lankan with an outswinger but there was no appeal for a catch behind, despite technology suggesting Mathews had edged the ball.
Mathews has hit 18 fours and a six while Nayeem and Shakib have bowling figures of 4-97 and 3-60 respectively.