Shakib Al Hasan's century and a fine knock from debutant Mosaddek Hossain propelled Bangladesh to a hefty lead over Sri Lanka in Colombo, despite Rangana Herath's landmark 1,000th first-class wicket on day three of the second Test.
Shakib, who had been dropped on 11 on day two, was put down again on 67 and punished Sri Lanka's wastefulness with a well-constructed fifth Test ton, in Bangladesh's 100th Test.
The all-rounder's luck ran out shortly before tea when Dinesh Chandimal took a fine catch at mid-on, but Mosaddek - who together with Shakib put on 131 for the seventh wicket - scored 75 as Bangladesh posted 467 all out for a first-innings advantage of 129.
The evergreen Herath, 38, had done his part to stem the Tigers' flow by dismissing Mehedi Hasan (24) and Mustafizur Rahman (0) with successive balls to become just the second Sri Lankan, after Muttiah Muralitharan, to reach 1,000 first-class wickets.
Dimuth Karunaratne (23) and Upul Tharanga (25) were unbeaten at stumps as Sri Lanka closed on 54 without loss, reducing their deficit to 75.
Bangladesh had wobbled at the end of the second day before closing on 214-5, but Shakib and skipper Mushfiqur steadied the ship on Friday - taking their partnership to 92 before the latter was undone by a Suranga Lakmal inswinger.
Chandimal missed an opportunity to run out Shakib, who was then put down by Niroshan Dickwella off Herath on 67 and duly capitalised, reaching three figures with a swept four off Dilruwan Perera.
Shakib holed out to mid-on off Lakshan Sandakan before tea, leaving Mosaddek to bear the main run-scoring responsibility.
Mosaddek had started patiently, but set the tone for a fine knock by launching Herath for six.
Herath trapped Mehedi and Mustafizur lbw with consecutive balls to bring up 1,000 first-class victims and Mosaddek's hopes of a century were ended when he misjudged a delivery from the veteran spinner to leave Dickwella with a simple stumping.
Sri Lanka, who lead the two-match series 1-0, were largely untroubled in the 13 overs that remained, although there was a life for Karunaratne when a diving Mushfiqur spilled a tough chance off Subashis Roy.