AUBURN HILLS, Mich. -- Miami Heat coach Erik Spoelstra paid center Hassan Whiteside a left-handed compliment. There was no disrespect involved in the remark.

Whiteside sustained a cut to his right hand that required 13 stitches last week. In the closing seconds on Tuesday night, Whiteside maneuvered the ball to his left hand and tipped it in just before the buzzer, giving the Miami Heat a 97-96 victory over the Detroit Pistons at The Palace.

"Hassan, maybe for the first time in his career, is playing more for the guys next to him than he is for himself, and that's what we've seen the last three games," Spoelstra said. "It was just poetic justice that he tipped it in with his left hand."

Whiteside scored after a wild scramble during which the Heat missed two attempts on their final possession. He finished with 17 points and nine rebounds.

James Johnson and Goran Dragic missed shots before Whiteside got his hands on the ball in traffic.

"I got my dirty left hand on it, and it went in," he said. "I lost the first (rebound) and then Goran got a second rebound. That was big. He threw it up there and I shot-tipped it in."

Dragic scored a game-high 28 points, Johnson had 16 points and six rebounds, and Rodney McGruder added 12 points for the Heat (36-38).

Miami retained a tenuous hold on the last playoff spot in the Eastern Conference chase after losing three of its previous four games. The Heat are one game up on the Chicago Bulls (35-39).

Miami, which was 19 games under .500 in mid-January, scored the final five points after giving away a nine-point lead during the quarter.

"We just got built like that. We're mentally tough," Whiteside said. "We've been in so many close battles like this."

Kentavious Caldwell-Pope's 25 points led the Pistons (34-41), who have lost eight of their last nine. Ish Smith and Tobias Harris scored 19 points apiece and Andre Drummond chipped in nine points and 13 rebounds.

"We said this morning that this was going to be a game that we're going to have to play through the last possession," Spoelstra said. "We understood how desperate they would come in and we were desperate for a win coming off of two losses. And it played out that way. That's just how crazy these games can be all the way to the end."

The loss was a devastating blow to Detroit's postseason aspirations.

"It's tough to lose like that," coach Stan Van Gundy said. "It's tough for me because I could have made better decisions that would've won us the game."

Miami played without shooting guard Dion Waiters for the fifth consecutive game. Waiters is nursing a sprained left ankle.

Detroit point guard Reggie Jackson sat out for the second consecutive night for rest. Jackson missed the first 21 games because of a knee injury and hasn't fully regained his explosiveness.

"It's extremely tough," Jackson said. "Last year, we were on the other end of it and this year it just feels like sometimes we just have bad breaks consistently throughout the season."

Johnson's dunk with 5:40 remaining gave Miami an 87-82 lead, but Detroit forged ahead just over a minute later. Caldwell-Pope made a corner 3-pointer and Drummond converted a three-point play after an offensive rebound.

Whiteside made one of two free throws with 1:56 left to put Miami on top at 92-91. After a couple of empty possessions, the Pistons regained the lead on Caldwell-Pope's 3-pointer with 45 seconds remaining.

After a McGruder turnover, Smith drained a jumper for a 96-92 Detroit advantage.

The Pistons' Stanley Johnson was called for a technical for guarding too closely during the ensuing inbounds play. Dragic made the free throw, then scored in the lane.

James Johnson then forced a jump ball against Stanley Johnson and won the tap, setting up Miami's winning possession.

NOTES: Detroit coach Stan Van Gundy said he will decide if or when PG Reggie Jackson will play again this season. Jackson sat out his second straight game because of fatigue. "It's strictly been my call all the way," Van Gundy said. "Reggie wants to be out there." ... The season series ended 2-2. ... Miami is 28-3 when leading after three quarters. ... Heat players have missed 295 games due to injury or illness this season, most in the NBA. ... Miami coach Erik Spoelstra views his top reserves, G Tyler Johnson and F James Johnson, as starters. "They make a lot of plays for us and they're unconventional, really intuitive plays," he said. "They're really our six and seven starters."