Skipper Rahim hit a solid 200 and Hossain an impressive 100 as Bangladesh were bowled out for 638, their highest total in 76 Tests, in reply to Sri Lanka's first-innings total of 570-4 declared.

The hosts reached 116-1 in their second innings at stumps on the penultimate day of the Test heading for a draw in Galle. Opener Tillakaratne Dilshan was unbeaten on 63 and Kumar Sangakkara 49 not out.

Rahim's memorable moment came in the second over after lunch when he pushed paceman Nuwan Kulasekara for a single to the covers on a day when Mohammad Ashraful (190) missed out on his own Test double-hundred.

Wicketkeeper-batsman Rahim, 24, was trapped leg-before by Kulasekara in the same over, but not before helping Bangladesh surpass their previous highest Test total of 556 against the West Indies in Dhaka last year.

Bangladesh, who dominated the match for a second successive day with their solid batting, also became only the third team after India and Pakistan to score 600 or more in a Test innings in Sri Lanka.

Rahim, 152 overnight, hit one six and 22 fours in his brilliant 321-ball knock. He put on a record 267 for the fifth wicket with Ashraful and 106 for the next with Hossain.

Bangladesh's previous highest stand for any wicket in Tests was 200 between Tamim Iqbal and Junaid Siddique against India in Dhaka in 2010.

Hossain was caught at mid-wicket by Sangakkara off part-time spinner Dilshan after hitting nine fours.

Ashraful, playing his first Test in more than a year, added just one to his overnight score when he went for a rash drive off left-arm spinner Rangana Herath and edged a catch to captain Angelo Mathews at first slip.

He occupied the crease for more than a day, hitting one six and 20 fours in his marathon 417-ball knock.

Ashraful earlier survived a confident appeal for a catch at leg-slip off the first ball of the morning while attempting to reverse-sweep Dilshan.