The second-wicket pair batted through the morning session of the third day's play to take the overnight score of 86-1 to 201 without further loss by lunch at the Zahur Ahmed Chowdhury stadium.
Shamsur, playing only his second Test, was unbeaten at the break on 93 with the help of nine boundaries and a six.
Left-handed Kayes celebrated his return to the Test side after two years with a stroke-filled 91 not out that included 15 fours and a six.
The duo had joined hands on Wednesday afternoon after Tamim was bowled by Suranga Lakmal off the fourth ball of the innings before a run had been scored.
Bangladesh, perhaps inspired by Kumar Sangakkara's triple-century on the second day, tamed the Sri Lankan attack on the sluggish pitch that tended to low at times.
It was a much-improved performance by the hosts who were thrashed by an innings and 248 runs in the first Test in Dhaka last week, their 14th loss in 15 matches against Sri Lanka with one draw.
