Maiden Test centuries from Imrul Kayes and Shamsur Rahman helped Bangladesh reach 409-8 in their first innings - still 178 behind - by the close of play on day three of the second Test against Sri Lanka in Chittagong.
Shamsur contributed 106 to a superb second-wicket partnership of 232 with Kayes, who himself made 115 after an earlier-than-anticipated arrival at the crease.
The efforts of the duo - who came together after opener Tamim Iqbal had fallen for a duck on day two - helped the hosts avoid the possibility of being forced to follow-on in a match they must win to earn a share of the series.
However, Ajantha Mendis claimed two wickets in as many balls late on to mean Sri Lanka still hold the upper hand after their first-innings total of 587.
Mendis finished Thursday's action with impressive figures of 4-84, though he and the rest of the visiting attack had struggled during the first two sessions.
Shamsur was the first to reach his ton in only his second Test when he hit Angelo Mathews for a four, but Kayes should have been denied his milestone when, two balls later, he was dropped by Kithuruwan Vithanage at point.
That would not be the only let-off before he reached three figures; Vithanage actually successfully caught him later in the same over, only for the umpire at the bowlers' end to be stood signalling for a no-ball.
Kayes' landmark moment arrived soon after, though neither he nor Shamsur managed to push on. Both were bowled by Mendis, their departures sandwiched in between Mominul Haque being trapped lbw by Dilruwan Perera.
Shakib Al Hasan (50) and Nasir Hossain (42) made useful contributions to carry Bangladesh past the follow-on target, though the latter was one of the batsmen to fall victim to Mendis not long before stumps.
Sohag Gazi was the other to depart, adjudged lbw to the first delivery he faced. Mahmudullah stood firm, though, to make an unbeaten 30.
It could well have been even worse for the home team had Dimuth Karunaratne not spilled a straightforward catch off Al-Amin Hossain (three not out) in the final over.
Sri Lanka won the first Test of the series by an innings and 248 runs in Dhaka.