Utah won its third in a row despite entering the fourth period with a seven-point deficit that grew to as many 13 early in the quarter.
The Jazz rallied to seize the advantage down the stretch, but Sacramento tied it at 102-102 on a 3-pointer by Marcus Thornton with 57 seconds remaining.
Sacramento regained the ball with a chance to go in front, but Jamaal Tinsley stole it back for the Jazz and Hayward took advantage of the opportunity to hit the game-winning shot.
An attempt to tie it by Sacramento's James Johnson misfired with 5 seconds to play.
Tyreke Evans led a balanced Sacramento attack with 19 points.