Sri Lanka and Bangladesh are set for a tense final day after the hosts lost eight wickets in establishing a 139 run lead on day four of the second Test.
Dimuth Karunaratne stood out for the hosts on what was not their best day as he stroked his way to a fifth Test century while no other batsman could get past fifty.
Mehedi Hasan provided Bangladesh with a much needed breakthrough early on the fourth day as he produced a ripper to account for Upul Tharanga (26) with his first ball of the day.
Karunaratne and Kusal Mendis (36) looked to have put Sri Lanka on top with an 86 run partnership that took the total to 143 before the latter's wicket sparked a collapse.
Dinesh Chandimal (5), Asela Gunaratne (7), Dhananjaya de Silva (0) and Niroshan Dickwella (5) all failed to get into double figures as Sri Lanka slumped to 190 for 6 with Mustafizur Rahman and Shakib-al-Hasan doing the damage.
When Shakib got Karunaratne for 126 nicking off to slip Sri Lanka were 217 for 7 leading by just 88 and looked ripe to be knocked over.
There was some great late resistance though by Dilruwan Perera (26 not out) and he was aided by Rangana Herath (9) and Suranga Lakmal (16 not out) who survived a final ball review and will resume the fight on day five.
Sri Lanka lead by 139 having reached 268/8 by the close of play but any sort of fifth day chase is likely to prove challenging for Bangladesh against the spin kings Herath and Lakshan Sandakan.
Mustafizur's figures of 3/52 make him the pick of the Bangladesh bowlers in this innings so far.