Kusal Mendis struck his maiden century before Taskin Ahmed claimed a hat-trick as Bangladesh dismissed Sri Lanka for 311 in the second one-day international in Dambulla, which was ultimately washed out.
Needing a win to stay alive in the three-match series, Mendis laid the foundation for a strong total with 102 from 107 balls before Taskin's late burst halted their progress.
Taskin took a catch off his own bowling to dismiss Mendis after a fierce straight drive from the batsman struck the bowler and ballooned up in the air. Taskin then removed Asela Gunuratne (39), Suranga Lakmal and Nuwan Pradeep in the final over to become the fifth Bangladeshi bowler to complete an ODI hat-trick.
He finished with 4-47 after Sri Lanka dominated the visiting bowlers initially having elected to bat first.
Mashrafe Mortaza removed opener Danushka Gunathilaka for nine but Mendis shared 111 runs with skipper Upul Tharanga for the second wicket to put Sri Lanka in a strong position.
A direct hit from Mahmudullah helped Bangladesh separate the duo as Tharanga was run out for 65, trying to complete a single off a no-ball from Mustafizur Rahman.
Mendis struck a six and a four in the next two balls to complete his fifty before racing to his century in 102 balls with a single off Mortaza.
He also shared 83 runs for the third wicket with Dinesh Chandimal, who chipped in with 24 runs.
But heavy rain after the innings break meant no further play was possible, meaning Bangladesh will take a 1-0 series lead into the series finale on Saturday.