Buttler, 26, hit an unbeaten 80 and Ali 70 in a stand of 139 as England chased down a target of 310 set by the Bangladesh Cricket Board Select XI.
The hosts were inspired by Imrul Kayes, who hit 121 from 91 balls, with Test captain Mushfiqur Rahim hitting 51.
England face Bangladesh in the first one-day international on Friday.
The tourists made a strong start to their reply, reaching 72-0 before Ebadat Hossain removed openers Jason Roy and James Vince.
Vince made a positive 48 after being promoted up the order in place of Alex Hales, who, along with captain Eoin Morgan, opted not to tour over concerns about security.
Uncapped Ben Duckett hit 29 before being bowled when his bat flew out of his hands as he attempted a reverse sweep.
England were 170-5 when Ali came to the crease and he hit eight fours while Buttlers 64-ball innings included four sixes as England reached their target with 23 balls remaining.
Kayes hit 11 fours and six sixes as he top scored with 121 from 91 balls in a sweltering Fatullah.
When the opener was bowled by David Willey, it left the BCB on 191-3 with 21 overs still to go in their innings.
Adil Rashid, who controversially missed Yorkshire's final County Championship game of the season last month, was the most expensive of the England bowlers, taking 1-76 in his 10 overs.
However, thanks to efficient bowling from Chris Woakes, Willey and Ben Stokes, England were able to take regular wickets to restrict the flow of runs.
Test captain Mushfiqur Rahim (51) and Nasir Hossain (46) helped take the total on to 283-6 but the tail added just 26 runs in the final five overs.
Jos Buttler and Moeen Ali guided England to a four-wicket victory in their only warm-up game before the one-day series in Bangladesh.