The Detroit Pistons refused to go quietly, edging the New York Knicks 106-103 on Tuesday night in Game 5 to extend their first-round playoff series.

Behind Cade Cunningham’s 24 points, eight rebounds, and eight assists, Detroit avoided elimination and cut the Knicks’ series lead to 3-2.

The Pistons, who entered the postseason after a 44-38 turnaround campaign, showed poise in a tight finish at Madison Square Garden.

Ausar Thompson delivered 22 points on 8-for-10 shooting, while Tobias Harris added 17 as the visitors outscored New York 11-8 in the final three minutes.

Jalen Duren contributed nine points, 14 boards, and six assists, anchoring Detroit’s interior against a Knicks frontcourt featuring Karl-Anthony Towns and Mitchell Robinson.

Detroit built a 101-95 lead late in the fourth after back-to-back baskets from Duren and a Cunningham floater.

New York’s momentum was disrupted when both Jalen Brunson and Josh Hart exited briefly with injuries under the three-minute mark, returning only with 27 seconds left.

Brunson, who had averaged 33.3 points through the first four games, was limited to 16 points on 4-of-16 shooting — his least productive outing of the series.

OG Anunoby led the Knicks with 19 points, while Towns and Mikal Bridges each had 17.

The Pistons now return to Little Caesars Arena for Game 6 on Thursday, aiming to snap a nine-game home playoff skid dating back to 2008.

If Detroit forces a Game 7, it will be played Saturday in New York.

The Pistons shot 42.4% from the field and went 26-of-36 at the line, while the Knicks finished at 43.3% but struggled from the stripe, converting just 59.3% of their free throws.

Mitchell Robinson posted a 13-point, 11-rebound double-double off the bench, but New York’s 13 turnovers and defensive lapses down the stretch proved costly.

Game 6 presents Detroit a rare opportunity to host a postseason game with momentum, while the Knicks look to regroup after squandering a closeout chance at home.