Sri Lanka 331 for 3 (Karunaratne 139*, Thirimanne 74*) trail Bangladesh 541 for 7 by 210 runs
Dimuth Karunaratne reached his 11th Test century as Sri Lanka had a near-perfect session on the fourth morning. They are now just 12 runs short of avoiding the follow-on, and are set up to challenge Bangladesh's total of 541 for 7.
Karunaratne had solid support from Dhananjaya de Silva, who was unbeaten on 74, as the pair put on 141 for the unbroken fourth wicket. The pair mainly blunted the Bangladesh attack, who by the end of the session, were reduced to waiting for the batters to make a mistake.
The day started with Karunaratne in search of his century, as he spent 30 balls in his nineties before reaching the three-figure mark. Shortly afterwards, he struck Taskin Ahmed for three fours in an over - a pull shot, an edge and a whip through midwicket.
Spin was brought on after seven overs of seam with the second new ball, but neither Taijul Islam nor Mehidy Hasan Miraz created any chances.
The Karunaratne-de Silva pair ran hard, taking plenty of twos and threes, as they blunted the bowling attack. Karunaratne struck 14 fours in his 290-ball stay, while de Silva collected nine boundaries.
On the third day, Sri Lanka had confidently reached 229 for 3 in 73 overs. Karunaratne and Thirimanne had added 114, their second successive 100-plus opening stand. Thirimanne played positively to make 58, falling lbw to Miraz at the stroke of tea.
Karunaratne remained solid at the other end, but saw Oshada Fernando and Angelo Mathews fall in the twenties after looking aggressive during their stay. Taskin Ahmed, in the middle of an impressive spell, strangled Fernando down the leg-side for 20, before Islam's over-the-wicket angle foxed Mathews who missed an attempted late-cut.
Karunaratne and de Silva had then survived despite edging through the slips and close lbw shouts in the last 45 minutes of the third day.
Mohammad Isam is ESPNcricinfo's Bangladesh correspondent. @isam84