Tamim made 127 off 142 balls while Shakib Al Hasan and Sabbir Rahman added two more fifties, helping the visitors pass their previous highest score of 265-9 against Sri Lanka.
Tamim, who struck 15 fours and a six on his way to his eighth ODI century, put on 144 runs with Shakib for the fourth wicket, also Bangladesh's best ever partnership against Sri Lanka.
Shakib hit 72 off 71 balls and looked heading towards a century before he swept a Suranga Lakmal delivery wide outside off-stump to be caught by Lakshan Sandakan at short fine leg.
Sent into bat first by Sri Lanka captain Upul Tharanga, Bangladesh lost opener Soumya Sarkar early when he edged Lakmal to wicketkeeper Dinesh Chandimal for 10.
More From This Section
But Tamim and Sabbir, who made 54 off 56 balls, added 90 runs for the second wicket to bring the innings back on track on what looked like a flat batting pitch at Rangiri International Stadium.
Tharanga took a brilliant reflex catch at short cover to end Sabbir's aggressive innings which contained 10 fours, including three in one over off Thisara Perera.
Bangladesh handed off-spinner Mehedi Hasan his ODI debut while Sri Lanka included Milinda Siriwardana.
The preceding two-Test series ended in a 1-1 draw.