The Bucks remained three games behind Indiana for the last playoff position in the Eastern Conference, but they have Charlotte between themselves and the Pacers.
Milwaukee had only a three-point lead before Bogut hit a hook shot with 1:10 to go. Gooden boosted the advantage to seven on a jumper with 43 seconds remaining.
Brandon Jennings led the Bucks with 25 points and Gooden had 22 points to go with 11 rebounds. Bogut scored 17.
Milwaukee visits Indiana Friday in what will be a critical contest in the playoff chase.
Toronto, which has lost five in a row, got 22 points from Andrea Bargnani. The Raptors held as much as a 12-point lead in the opening period.
Celebrity Couples of 2014 [PHOTOS]