Lasith Malinga became the fifth man to take a Twenty20 international hat-trick but it was not enough to prevent Sri Lanka losing by 45 runs to Bangladesh.
The paceman bowled Mushfiqur Rahim and Mashrafe Mortaza before trapping Mehedi Hasan lbw in his final over to finish with 3-34 as the tourists made 176-9.
It was the 33-year-old’s sixth game back following a year out injured.
Chamara Kapugedera struck 50 in the reply but Mustafizur Rahman’s 4-21 helped dismiss the home side for 131.
The result ended an eight-match losing streak for Bangladesh and meant the two-match series was drawn after the hosts won the opener by six wickets on Tuesday.
Shakib al Hasan top scored for Bangladesh with 38 off 31 balls after Imrul Kayes (36) and Soumya Sarkar (34) had put on 71 for the first wicket.
Shakib also starred with the ball, claiming 3-24 off his four overs, including the wickets of both Sri Lanka openers, Kusal Perera and Dilshan Munaweera.
Malinga has taken four international hat-tricks and 89 Twenty20 wickets for his country.
He retired from Test cricket in 2011, having claimed 101 wickets, and has 291 in 191 one-day international appearances.