Bangladesh, trailing by 488 runs on the first innings, were 233-5 in their second knock when bad light stopped play 10.3 overs early on the third day at the Sinhalese Sports Club.
The tourists still need another 255 runs to make Sri Lanka bat again with five lower order wickets in hand.
Bangladesh, who were shot out for 89 in the first innings, put on an improved batting display the second time as opener Javed Omar hit 62 and Rajin Saleh chipped in with 51.
Bangladesh were cruising at 227-3 in the final session when Sri Lanka hit back with the wickets of Saleh and captain Mohammad Ashraful in the space of four runs.
Part-time spinner Tillakaratne Dilshan ended a fourth-wicket stand of 67 between Saleh and Ashraful when he forced Saleh to edge a catch to Sri Lankan skipper Mahela Jayawardene in the slips.
Three overs later, Ashraful needlessly holed out in the deep off Muttiah Muralitharan after looking well-set on 37.
When stumps were drawn, Shakib-Al Hasan was batting on four and Khaled Mashud had not got off the mark.
Openers Omar and Shahriar Nafees, who began the day at the overnight score of three for no loss, frustrated the Sri Lankans by carving out 86 for the first wicket.
It was Bangladesh's best opening stand against Sri Lanka, surpassing the 52 between Omar and Nafees Iqbal at home in Bogra last year.
Omar began by driving Chaminda Vaas through the covers thrice in one over and then flicked two consecutive boundaries off Lasith Malinga at the other end.
Left-handed Nafees straight drove Vaas and pulled Malinga before bringing up the 50 partnership in 55 minutes by lofting off-spinner Muralitharan for a four.
Muralitharan, who bagged five wickets in the first innings, finally broke through 30 minutes before lunch when he accepted a hard return catch off a Nafees straight drive.
Nafees made 38 with seven boundaries.
Omar, who was 52 at lunch, added 10 more runs when his brave knock was ended by a vicious yorker from Malinga that trapped the batsman in front of the wicket and injured his right toe.
Omar limped off the field after his eighth Test half-century that was studded with 10 boundaries.
Habibul Bashar made 17 when he hung his bat out to an Vaas outswinger and was snapped up behind the stumps by Prasanna Jayawardene.
Saleh and Ashraful carried the score from 160-3 to 227 before Bangladesh were set back by the dismissal of both batsmen.
Sri Lanka had piled up 577-6 declared in their first innings with Mahela Jayawardene, opener Michael Vandort, wicket-keeper Prasanna Jayawardene and Vaas scoring centuries.
Bangladesh will play three Tests and as many one-day internationals on the Sri Lankan tour that ends on July 24.