Somehow, the Knicks aren’t dead yet.

While president Phil Jackson seemed to give last rites to the 2013-14 season after their horrific blowout loss at Staples Center to the Lakers, the Knicks moved to the northern part of California and kept alive their slim playoff hopes Wednesday. Barely.

The Knicks (30-42) built a 24-point lead in the third quarter and nearly blew all of it in trademark fashion before hanging on 107-99 at Sleep Train Arena, thanks to J.R. Smith’s clutch brilliance from the 3-point line.

Jackson already talked late Tuesday about being on “a talent hunt’’ for next season, but with Atlanta’s collapse, the Knicks are still in it. They moved two games behind the fading Hawks for the final playoff spot with 10 games left as Atlanta got blown out in Minnesota.

“We bounced back,’’ coach Mike Woodson said. “That’s the fun part about this game. One day you’re down. The next day you’re back on your feet.’’

Smith banged in three giant 3-pointers in the fourth quarter to finish with 29 points. He wound up 9-of-12 from the 3-point stripe, tying a franchise record. Carmelo Anthony, who tweaked his right ankle late, added 36 points to hold off a massive Kings’ charge.

Anthony said he will be ready when the Knicks continue their make-or-break West Coast trip in Phoenix on Friday.

“Throughout all this, we still have a chance to get in the postseason,’’ Anthony said. “Once you’re in the playoffs, nobody looks at the regular season. Everyone starts 0-0. Our goal is to get there.’’

Sacramento cut the lead to 96-94 on a DeMarcus Cousins 3-point play with 4:30 left. Cousins was a load all evening, finishing with 32 points, 15 rebounds and eight assists.