Ashraful hit an unbeaten 189 not out, the highest by a Bangladeshi in Tests, on his comeback and Rahim made a career-best 152 not out as the tourists posted 438-4 in their first innings at stumps in reply to Sri Lanka’s 570-4 declared.
Their 261-run unbroken stand was Bangladesh’s highest for any wicket in Tests, the previous best being 200 for the second wicket between Tamim Iqbal and Junaid Siddique against India in Dhaka in 2010.
Bangladesh also surpassed their previous highest total of 413 against Sri Lanka in Tests.
The tourists, who avoided the follow-on in the final session, now trail by 132 runs with six wickets in hand.
The 28-year-old Ashraful, who played his last Test in December 2011, hit one six and 20 fours in his sixth Test hundred, and the fifth against Sri Lanka, while Rahim, 24, smashed one six and 18 fours in his second Test century.
“We needed a partnership and I had one with Mushfiq. The wicket was very nice and I believed if I don’t make any mistake I won’t be out,” said Ashraful.