Bangladesh tailender Mashrafe bin Mortaza hit a remarkable half century on Sunday to steer the hosts away from a follow-on, but Sri Lanka still finished day two of the second Test in a commanding position.
Sri Lanka was bowled out for 384 early Saturday and was in a prime position to enforce the follow-on when Bangladesh slid to 145-9 in reply.
However Mortaza (63) and No. 11 Shahadat Hossain put on 63 runs for the final wicket - of which Hossain contributed just five - to avoid the follow-on.
At stumps, Sri Lanka was 13-0 in its second innings.
Bangladesh started the day promisingly, taking the last four Sri Lanka wickets for only eight runs within 25 of the start of play, but their batting followed the pattern of the first Test, getting starts but being unable to form any good partnerships.
Sri Lanka paceman Chaminda Vaas (2-21) got opener Tamim Iqbal (0) caught behind by Prasanna Jayawardene without a run on the board and then trapped Imrul Kayes (6) lbw. Spinner Ajantha Mendis removed Raqibal Hasan for a duck to have the home side at 33-3.
Junaid Siddique and captain Mohammad Ashraful put on 32 runs for the fourth wicket before Dilhara Fernando bowled Siddique (28).
Bangladesh slumped to 90-6 after Mendis claimed lbw wickets with successive balls, removing Mehrab Hossain (18) and Shakib Al Hasan (0).
Ashraful (45)and wicketkeeper Mushfiqur Rahim raised the score to 122 when the captain was caught behind off Muttiah Muralitharan.
After tea, Rahim (21) was next to go, stumped by his counterpart Jayawardene off Mendis. Then Muralitharan had Enamul Haque (4) caught behind and Bangladesh looked condemned to a follow-on.
However Mortaza then took over, with his spirited 63 coming off 89 balls with eight fours and two sixes. He was caught by Tillakaratne Dilshan off Muralitharan trying for another big hit.
It was the first Test half-century for Mortaza, who finished with 3-58 with the ball.
Mendis returned figures of 4-71, and his spin partner Muralitharan took 3-62
Sri Lanka strike back as Bangladesh struggle
Daily Nation, Kenya
Mortaza believes comeback still possible
Sri Lanka leave Test rivals in a spin
Bangladesh avoid follow on but Sri Lanka on top
Reuters India, India