The Raptors took a one-point lead with 7:12 left on a pair of foul shots from Linas Kleiza, but Milwaukee then went on a 12-2 run to take control.
Carlos Delfino led the Bucks with a season-best 25 points, helping Milwaukee snap a three-game losing streak.
Drew Gooden chipped in 20 points and 14 rebounds for Milwaukee. Dunleavy finished with 18 points.
DeMar DeRozan had 25 points for Toronto, hitting 4-of-6 from 3-point range. The Raptors have won only three home games in 10 tries this season.