Sanchez heard boos from the crowd for much of the game, taking the heat for the Jets' disappointing 5-5 record coming into the contest.
But he silenced them with 1:01 left with his 16-yard TD toss to Holmes in the corner of the end zone, giving New York a much-needed win to stay alive in the AFC wild card race.
The Jets signal-caller ended with a career-high four touchdown passes, gaining 180 yards and overcoming an interception as New York snapped a two-game skid.
Buffalo (5-6), meanwhile, continued its slide, losing its fourth consecutive game.
Ryan Fitzpatrick completed 26-of-39 passes for 264 yards and three touchdowns for the Bills.
Trader Joe's: Car crashes into Long Island store, injuring 11
Selena Gomez drops F-bomb, walks off stage during Jingle Ball performance