Cade Cunningham delivered in the clutch, banking in a three-pointer with less than a second left to lift the Detroit Pistons to a 116-113 victory over the Miami Heat on Wednesday night.

The Pistons (39-31) trailed for most of the second half and never led by more than two points until Cunningham’s game-winning shot. The loss extended Miami’s (29-40) losing streak to nine games.

Cunningham recorded his ninth triple-double of the season, finishing with 25 points, 12 rebounds, and 11 assists. He became just the fourth player to post multiple triple-doubles against the Heat in a single season, joining James Harden, Domantas Sabonis, and Nikola Jokic.

Bam Adebayo led Miami with 30 points, nine rebounds, and eight assists, but the Heat faltered down the stretch. They entered the fourth quarter with a 93-88 lead and were ahead by eight in the final period before Detroit’s late surge.

Tyler Herro added 29 points for Miami and had a plus-eight rating in his 37 minutes on the floor. However, the Heat were outrebounded 47-37 and surrendered 70 points in the paint.

Cunningham scored Detroit’s final two baskets, both three-pointers, including the decisive shot in the closing seconds. His performance helped the Pistons solidify their position as the sixth seed in the Western Conference playoff race.