Tillakaratne Dilshan's 17th one-day century proved in vain on Thursday as Bangladesh beat Sri Lanka by three wickets under the Duckworth/Lewis rain rule to win the third and final one-day international and share the series one-all.
Sri Lanka looked to be in control when they ran up an impressive 302 for nine after choosing to bat first.
But Bangladesh whose run chase was interrupted in the 14th over when they were 78-1, were then set a revised target of 183 to win off 27 overs.
They were given a splendid start by Anamul Haque (40) and Mohammad Ashraful (29) who posted 77 at a run-a-ball.
Despite losing wickets at regular intervals Bangladesh were taken over the line with an over to spare by Nasir Hossain who struck Thisara Perera for four fours in the penultimate over.
Nasir made 33 not out as Bangladesh finished on 184-7.
"It's a huge win for us, it was a challenge for us to do well against big teams, so very happy with the effort,'' Bangladesh captain Mushfiqur Rahim said.
Sri Lanka captain Mathews said he is disappointed with the loss despite having a strong total on the board.
"The bowling let us down today,'' he said. "We batted brilliantly even though we lost out way in the middle.''
Earlier man-of-the-match and man-of-the-series Dilshan with 125 off 128 balls, including 12 fours, and Kusal Perera provided Sri Lanka with a fine launchpad, putting together an opening stand of 116 off 127 balls.
Perera's contribution in the partnership was 56, his maiden one-day half-century.
Kumar Sangakkara helped Dilshan add a further 87 for the second wicket by scoring 48. During his knock Sangakkara became the first Sri Lankan and seventh batsman overall to pass 11,000 runs in one-day international cricket.
There was also a milestone for Bangladesh left-arm spinner Abdur Razzak who ran through the Sri Lanka middle order to take five for 62 and become the first bowler from his country to take 200 one-day wickets.
Bangladesh complete their five-week tour of Sri Lanka on Sunday when they take on the hosts in a one-off Twenty20 international at the same venue.