Mohammad Ashraful and Mushfiqur Rahim posted centuries Sunday to help Bangladesh to 438 for four in reply to Sri Lanka's 570 for four declared on the third day of the first Test at Galle International Stadium.
Bangladesh still trail by 138 runs.
The experienced duo put together an unbroken 261-run stand, the highest for Bangladesh for any wicket, breaking the previous best of 200 between Tamim Iqbal and Junaid Siddiq against India.
Their stand is also a new record at Galle for any wicket by any team.
Sri Lanka first innings 570-4 declared
Bangladesh first innings (135-2 overnight)
J Islam c Chandimal b Eranga 20
A Haque b Mendis 13
M Ashraful not out 189
M Haque c Mathews b Kulasekara 55
Mahmudullah st Chandimal b Herath 0
M Rahim not out 152
Extras (b-2, lb-1, nb-6) 9
Total (for four wickets in 136 overs) 438
Fall of wickets: 1-23, 2-65, 3-170, 4-177.
To bat: Nasir Hossain, Abul Hasan, Sohag Gazi, Elias Sunny, Shahadat Hossain.
Bowling: Kulasekara 21-3-76-1 (nb-1), Eranga 22-3-80-1 (nb-5), Herath 42-9-103-1, Mendis 23-2-92-1, Mathews 6-1-16-0, Dilshan 20-3-55-0, Thirimanne 2-0-13-0
Ashraful, Bangladesh's former captain and the most experienced player with 58 Tests played, wasn't part of the original squad and only injuries to other players gave him his chance. Playing his first Test since 2011, the 28-year-old posted the highest score by a Bangladeshi batsman in an innings, breaking his own record.
The previous best was his unbeaten 158 against India. He was unbeaten on 189 at stumps and is set to become the first Bangladeshi to score a double hundred.
During his knock, Ashraful became the 11th batsman to score 1000 Test runs against Sri Lanka. Of his six Test hundreds, five have come against Sri Lanka.
Bangladesh lost overnight batsman Mominul Haque for 56 in the morning and soon afterwards Mahmudullah perished without scoring, but the fifth wicket partnership helped Bangladesh avoid the follow on. This is also Bangladesh's best total away from home in a Test. Their previous best total was 416 all out against West Indies in St. Lucia in 2004.
Ashraful, who had made a hundred on debut against Sri Lanka in 2001, reached his sixth Test century with a glorious cover drive in the morning session off Ajantha Mendis.
Mushfiqur reached three figures after tea with a sweep shot, also off Mendis. He was unbeaten on 152 off 239 balls with 18 fours and a six.
Sri Lanka put down tough chances off both batsmen.
The partnership helped Bangladesh's chances of drawing the match. Sri Lanka has won all 12 Tests against Bangladesh.
In the morning session, Sri Lanka dismissed overnight batsman Mominul Haque when he was caught at first slip by Angelo Mathews off the bowling of Nuwan Kulasekara. They got a second wicket a short time later when Mahmudullah attempted to clear the ground before getting off the mark, but missed the ball completely and was stumped by Dinesh Chandimal.