Sri Lanka, the world's top-ranked Twenty20 side, made 168-7 after being sent in to bat and then restricted Bangladesh to 166-7 to take the lead in the two-match series.
With Bangladesh needing 17 runs from the final over, Anamul smashed 14 runs off the first five deliveries, but then gave Perera a return catch with the last ball.
Anamul returned disappointed after making a gallant 58 off 45 balls with seven boundaries, including three in the tense final over.
Shakib Al Hasan helped Anamul add 43 for the third wicket, but Bangladesh lost four quick wickets to slip from 107-2 in the 14th over to 158-6.
Anamul faltered when it mattered most to leave Sri Lanka victors as Thisara Perera and Nuwan Kulasekara finished with two wickets each.
For Sri Lanka, left-handed opener Kusal Perera top-scored with 64 off 44 balls, but he found little support from the rest of the top order batsmen.
Kulasekara made 31 off 21 balls with one four and two sixes, while Thisara Perera returned unbeaten on 19.
Mashrafe Mortaza led the hosts after regular captain Mushfiqur Rahim was rested due to a hairline fracture in the left hand and Tamim Iqbal stepped down as vice-captain to concentrate on his batting.
Sri Lanka were without frontline batsman Mahela Jayawardene, who is missing the entire limited-overs series of two Twenty20 games and three one-day internationals due to a hand injury.
The second Twenty20 game will also be played in Chittagong on Friday.
