NEW YORK — The Boston Celtics, battling for the eighth and final spot in the Eastern Conference playoffs, won for just the second time in their last six games, defeating the New York Knicks 96-92 on Friday night at Madison Square Garden.

Boston (32-40) entered the game with a half-game lead over Indiana, Brooklyn and Charlotte for the final spot.

The Celtics were led by guard Isaiah Thomas, who poured in 18 points off the bench. Forward Jae Crowder accumulated 17 points and nine rebounds and forward Brandon Bass had 16 points and 10 rebounds.

The Knicks (14-59) have lost 59 games in a season four times, most recently in 2007-08. New York dropped its fifth straight game and the 21st in its last 25.

Center Andrea Bargnani paced the Knicks with 25 points and seven rebounds. Guards Shane Larkin and Langston Galloway added 14 and 12 points, respectively.

The Celtics converted 10 of their 13 free throws in the final 1:47 of the game to preserve the win.

With two minutes to play, the Knicks were able to get within five points at 86-81 for the second time in the fourth quarter. However, three free throws from Crowder moved the Boston lead to 89-81 with 1:12 remaining.

New York cut the Boston lead to 80-75 with 6:24 remaining in the game, then the Celtics went on a 6-0 run to move ahead 86-75 with 4:09 to go. Guard Evan Turner (15 points) contributed four points in the spurt.

A Larkin layup brought the Knicks to within 53-52 with 5:23 left in the third quarter, but Boston manufactured an 8-2 run to stay ahead 61-54 two minutes later. The Celtics added a 7-0 burst to end the quarter for a 70-63 cushion.

New York’s first-quarter lead quickly evaporated when Boston, trailing 24-23 early in the second quarter, went on a 14-4 run en route to a 47-39 halftime edge. Bass and Crowder scored six points apiece for Boston in the quarter.

The Knicks led in the first quarter for the first time in seven games, shooting 55.6 percent from the floor for a 22-21 edge. Larkin led the way with eight points.

The Celtics have been outscored in the first quarter in each of their last six games.

NOTES: The Knicks were without G Jose Calderon (strained left Achilles tendon), G Tim Hardaway Jr. (sprained right wrist), G Alexey Shved (rib contusion) and F Travis Wear (sore lower back). … In the Knicks 111-80 loss to the Clippers on Wednesday, Los Angeles shot 56. 4 percent from the field, the highest percentage this Knicks have allowed this season. … Former Knicks guard and current TV analyst Walt “Clyde” Frazier turns 70 on Sunday. … Boston PG Isaiah Thomas played his second game after missing eight games with a bruised lower back.