Bangladesh reached 81-3 at stumps, still needing 119 to make Sri Lanka bat again. The visitors declared their first innings at 713-9 in the final session.
Off-spinner Dilruwan Perera dismissed Imrul Kayes for 19 before left-arm unorthodox bowler Lakshan Sandakan got Tamim Iqbal caught behind for 41.
Herath then removed Mushfiqur Rahim for two with his left-arm spin in the last over of the day.
Mominul Haque -- 18 not out -- was at the crease when the players walked back after another run-filled day.
More From This Section
Left-arm spinner Taijul Islam, who returned figures of 4 -219, took two wickets off his successive overs to wrap up the Sri Lankan innnings.
Taijul got the all-important wicket of skipper Dinesh Chandimal for 87 before off-spinner Mehedi Hasan removed Niroshan Dickwella for 62 to slow down the Sri Lankan progress.
Debutant left-arm spinner Sunzamul Islam got his maiden Test wicket, trapping Dilruwan Perera leg-before for 32.
Roshen Silva joined the run fest in the morning session to post his maiden Test century after Sri Lanka resumed on 504-3.
Silva was Sri Lanka's third century maker of the innings after Kusal Mendis and Dhananjaya de Silva, who made 196 and 173 runs respectively.
Mehedi ended Silva's impressive innings when the right- hander edged a low delivery to wicketkeeper Liton Das.
Silva shared a 135-run stand with Chandimal for the fourth wicket and hit six fours and a six.