A century for Dinesh Chandimal and three late wickets in the space of seven deliveries helped put Sri Lanka in command on day two of the second Test against Bangladesh in Colombo, where the tourists trailed by 124 runs.
Resuming on 86 with the hosts at 238 for seven overnight, Chandimal chalked up his eighth Test hundred as Sir Lanka were eventually all out for 338.
Bangladesh, who were playing their 100th Test match, lost opener Tamim Iqbal for 49 and Soumya Sarkar for 61 before three costly late wickets saw their progress checked to 214 for five at stumps.
Earlier, Bangladesh had hoped to mop up the Sri Lanka tail quickly once captain Rangana Herath had departed for 25 following a thick edge off Shakib Al Hasan to Soumya at first slip with the total at 250.
However, Suranga Lakmal, who finished with a battling 35, helped Chandimal bring up his century and provide some late resistance as Sri Lanka moved past 300.
Chandimal, though, needed a review to remain at the crease when on 113 after he was initially given out caught behind off Mustafizur Rahman, with replays showing their was no contact with his bat.
Eventually, Bangladesh had Chandimal dismissed just before lunch when an attempted sweep off Mehedi Hasan fell to Mosaddek Hossain at midwicket, his 138 coming off 300 deliveries as he left the field at the P Sara Oval to a standing ovation.
In reply, Tamim and Soumya put on an opening 95-run partnership before Sri Lanka made the breakthrough just before tea when Tamim was trapped lbw by Herath just one run short of a half-century. Soumya was then bowled by Lakshan Sandakan, with Bangladesh at 130 for two.
Imrul Kayes, who suffered an injured toe whilst fielding, had added 34 when he went the same way in the 57th over as Sandakan struck him on the pads in front of off stump.
Nightwatchman Taijul Islam was then sent straight back to the pavilion next ball without troubling the scorers after Sandakan's delivery spun back in sharply, with the dismissal given on review .
Bangladesh's earlier hard work was quickly being undone during the closing session as Sabbir Rahman gloved a short delivery from Suranga Lakmal to leg gully where Dhananjaya de Silva took a diving catch to leave the hosts at 198 for five.
Shakib Al Hasan finished 18 not out and captain Mushfiqur Rahim on two as Bangladesh edged through to the close without suffering any more losses.
Sandakan ended the day with three for 65 to help Sri Lanka wrestle back the advantage.