Toronto and the Chicago Bulls, who beat Washington on Saturday night, are 45-32 and tied for the third seed in the Eastern Conference with five games to play.
Milwaukee fell to an NBA-worst 14-63, guaranteeing the team's worst record in its 45-year history.
Greivis Vasquez tied a season-high with 26 points for Toronto, which has won three consecutive games and six of seven. Vasquez, who averages 9.1 points, made up the scoring lost when starting point guard Kyle Lowry missed the game with a bruised left kneecap.
DeRozan made six free throws in the final 24 seconds to seal the victory.
Khris Middleton scored 20 points for Milwaukee, which has lost 13 of 14 games. Middleton made 6 of 9 shots after a shooting slump in which he made 14 of 41 over the past four games.
DeRozan made a pair of free throws to give the Raptors a 98-94 lead with 24 seconds left. Giannis Antetokounmpo then made two free throws to pull Milwaukee within 98-96 with 20 seconds left.
DeRozan made two free throws to give Toronto a 100-96 lead with 18.6 seconds to go. Jeff Adrien dunked with 11 seconds left, but DeRozan made two more free throws to cap the scoring.
Both teams played short-handed for the second consecutive night. Lowry and starting forward Amir Johnson were out with injuries for Toronto.
Milwaukee had only eight players available due to injuries.
There were nine lead changes in the fourth quarter, but Vasquez hit a 3-pointer to give Toronto the lead for good at 86-84 with 5:24 left. DeRozan then hit a free throw and made a 22-foot jumper to give the Raptors an 89-84 lead.
The Bucks pulled within 89-88, but DeRozan scored on a driving runner and Jonas Valanciunas converted a 3-point play to give the Raptors a 94-88 lead with 1:43 to go.
Middleton had 14 points to help Milwaukee lead 57-46 at halftime. The Bucks dominated down low in the first half, outscoring Toronto 38-14 in the paint.
NOTES: F Chris Wright was signed to his second 10-day contract by the Bucks on Saturday. ... The PA announcer drew big cheers from the Bradley Center crowd with periodic updates of the Wisconsin-Kentucky game in the NCAA tournament. ... The 1993-94 Bucks went 20-62, the team's previous worst record. ... Toronto's 45th win ties for the franchise's third most wins in a season. The team needs two wins in its final five games to match the team-record 47 wins, set in 2000-01 and 2006-07.