Kumar Sangakkara became only the second cricketer to hit a triple century and a hundred in the same test as Sri Lanka set Bangladesh a huge target of 467 to win the second and final match in Chittagong.
Sangakkara, who struck his maiden triple century in the first innings, hit a six off Sohag Gazi to reach three figures in the second and emulate former England opener Graham Gooch's 1990 feat against India at Lord's.
His tally of 424 fell just short of Gooch's record of 456 for most runs in a single test.
His partner in a fourth-wicket stand of 145, Dinesh Chandimal, struck his third test century as Sri Lanka declared on 305 for four half an hour just before the close.
Bangladesh openers Tamim Iqbal and Shamsur Rahman then survived eight overs to leave their side on 12 for no wicket.