The Pistons were within four points inside the final minute, but missed two straight shots and turned the ball over as well while Toronto was clinching the game from the foul line.
DeMar DeRozan led Toronto with 23 points in what was the Raptors' fourth straight victory. Toronto had captured only four of its first 23 games this season before going on its current four-game streak.
Anderson pitched in 16 points for the Raptors and Jonas Valanciunas had 12.
Toronto overcame a career-best 35 points and 10 rebounds from Greg Monroe. Detroit has won just twice in 15 road outings.