Updated

All on the same play in the second quarter, LeBron James twisted his left ankle, lost the ball and took a knee in the forehead from teammate Joel Anthony.

Safe to say, the Miami Heat felt no pain in a joyous postgame locker room.

Eddie House hit two deciding free throws with 6.5 seconds left, James led all scorers with 39 points and the Heat rallied late to beat the Detroit Pistons 88-87 on Friday night.

James finished with nine assists and eight rebounds for the Heat, who played without Chris Bosh and Dwyane Wade and trailed by 10 late in the third quarter. House had 15 points and Mike Miller added 12 for Miami, which had lost five of its last six games.

Ben Gordon scored 21 points for Detroit, which had a chance to win it on the final play, but Austin Daye's dunk attempt after a pass by Tayshaun Prince bounced off the rim. Daye was closely guarded by a leaping James Jones, but replays indicated the dunk try simply skipped off the rim.

House threw the ball skyward as time expired, and Miami escaped.

House's game-winning points came after he tried a pullup against Ben Gordon, who hit him on the shot attempt. House made both free throws for a one-point lead, and Detroit called time to set up a final play.

Miami had a foul to give, and James used it with 2.7 seconds left, forcing Detroit to draw up another last-ditch try. From the right sideline, Prince threw a lob to Daye, who tried to dunk from the left side but couldn't convert.

It was just the second time in 10 tries that Miami won a game decided by fewer than five points this season.

Wade sat out with a sprained right wrist, the second time a malady kept him sidelined in the past week. He missed Miami's game against Toronto with a migraine headache last Saturday. Bosh remained sidelined with a sprained left ankle.

Detroit was depleted as well.

The Pistons were without starting guard Rodney Stuckey, who sat out with a bruised right shoulder. He got hurt in a collision with Denver's Carmelo Anthony on Wednesday night. Richard Hamilton was out with the flu, and Ben Wallace was not with the team to tend to a family matter.

Daye had 19 points and nine rebounds, Tracy McGrady finished with 14 points, 10 assists and eight rebounds, and Chris Wilcox had 10 points and 10 rebounds for the Pistons.

With all the absences, the rotations were wild — as was the finish.

Miami missed 17 of its first 20 attempts from 3-point range, then got one from House with 4:20 remaining to tie the game at 80. And when James connected — the ball barely getting over the rim — from straightaway with 3:01 remaining, Miami took its first lead since the opening quarter, 83-82.

When the Knicks beat Miami on Thursday, New York was able to work the ball for two clutch open perimeter shots late.

Detroit must have been watching.

Daye was left alone with 1:07 remaining, hitting a 3-pointer from near the Heat bench to put Detroit up 87-86. It stayed that way until 6.5 seconds remained, when House got fouled while trying a 15-footer and hit both free throws.

James played the final 32:19 of the game.

Detroit led most of the first half, though never by any more than eight, and took a 42-39 lead into halftime.

Given the way Miami was playing, the Heat might have considered themselves fortunate.

Miami missed 13 of 14 shots from 3-point range in the half, had eight turnovers to Detroit's two, and relied almost entirely on James for all its offense. James shot 10 for 16 in the half, his 23 points representing his best first two quarters of the season.

The rest of the Heat in the first half? They shot 6 for 26, good for 16 points.

McGrady missed all eight of his shots in the opening half, then found his rhythm in the third quarter with nine points — including a layup with 2:52 left in the period that gave Detroit what was its biggest lead, 66-56.

Miami made a dent by the time the third quarter ended, House banking one in with 12 seconds left to get Miami within 68-64 entering the fourth.

And House came up even bigger late in the fourth, dancing to the Heat bench after the second free throw went down.

NOTES: One of the greatest backcourts in NBA history — Florida International coach Isiah Thomas and Detroit president Joe Dumars — sat together for the game. ... Highlights of last week's fundraiser at Heat president Pat Riley's home were shown during a first-half timeout, including Riley twirling an autographed Bruce Springsteen guitar that was auctioned off for charity. ... McGrady reached double-digits in assists for the second time this month. He had 11 against Utah on Jan. 3.