Gay's score-tying basket with 20.8 seconds remaining in regulation sent the game into overtime and Thomas secured the victory with a score late in the extra time for Kings, who had erased a 12-point second-half deficit.
DeMarcus Cousins provided 19 points and 14 rebounds, but missed the overtime after sustaining a strained left hip flexor.
Carmelo Anthony pumped in 36 points and grabbed 11 rebounds for the Knicks, losers of four in five.
Amar'e Stoudemire netted 20 points and Tyson Chandler totaled 17 with 11 rebounds.
Notable deaths of 2014 [PHOTOS]