Morris Peterson added 19 points for the Raptors and Williams contributed 10.
Williams made two free throws with 12 seconds left to blunt a Sacramento charge and give Toronto a six-point cushion. A three-pointer by Sacramento's Mike Bibby at the buzzer accounted for the final score.
Bibby led Sacramento with 32 points and Brad Miller had 14.
The Kings got back in the game late after trailing by 15 to start the fourth period. They had won their previous three games.