MarShon Brooks scored 17 points, 15 of them in the final quarter, and Kelly Olynyk fouled out with 13 points and nine rebounds for the Celtics.

Boston had a chance to tie it on the final possession, but Jared Sullinger couldn’t tip in Jordan Crawford’s missed 3-pointer.

Vitor Faverani and Jeff Green each scored 13 for the Celtics, who were coming off an 82-80 loss to former teammate Paul Pierce and the Brooklyn Nets on Tuesday.

Kyle Lowry scored 11 points and Rudy Gay and Jonas Valanciunas each had 10 for the Raptors, who won their third straight and improved to 4-1 in the preseason.

Gay, Lowry and Amir Johnson played the entire first quarter, but spent the rest of the night on the bench. DeMar DeRozan joined them after playing just over one minute in the second.

The Raptors used a 10-0 run in the final 4:36 of the third quarter to take an 80-70 lead into the fourth. Boston missed seven straight field goal attempts after Green’s dunk with 4:50 to go in the third put them up 70-69, their final lead of the game.

Brooks hit a 3 with 24 seconds left to cut it to 97-95, but Julyan Stone answered with a pair of free throws for the Raptors. Stone then missed a layup with seven seconds to go, setting up the frantic finish.