MIAMI — The way the Miami Heat saw it, this was a reward.

Goran Dragic had 21 points and eight assists, Wayne Ellington scored 18 off the bench and the Heat — saddled with one of the worst records in the NBA — overcame another triple-double from James Harden to beat the Houston Rockets 109-103 on Tuesday night.

Dion Waiters scored 17, Tyler Johnson had 16 and James Johnson added 15 for the Heat, who trailed by a point midway through the fourth quarter before putting the game away with a 20-5 run.

"I'm glad to see our guys get rewarded finally for all the work, but that doesn't guarantee anything," Heat coach Erik Spoelstra said. "We talk about it all the time. You keep on putting in deposits, to the team, to the work, continue to work to get better ... trust that process."

Harden had 40 points, 12 rebounds and 10 assists for the Rockets (32-12), his 13th triple-double of the season. He shot 12 for 30 from the field and got his triple-double with an assist to Montrezl Harrell with 12.6 seconds left, an uncontested dunk with the Heat simply waiting for the clock to run out.

Harrell had 13 points for the Rockets, who got 12 from Patrick Beverley.

"They played hard and they beat us," Houston coach Mike D'Antoni said. "There's not much else to say."

Hassan Whiteside added 14 points and 15 rebounds for Miami in a game that had 19 lead changes and 15 ties.

Dragic found Ellington for a corner 3 with 1:41 left to give Miami an 11-point lead — the largest either team had to that point. The Rockets turned it over on their next possession, James Johnson got a runout dunk and the Heat (12-30) soon finished off the win.

"We got open shots. We just missed them," Harden said. "We gave ourselves a chance, especially in that third quarter. Fourth quarter we didn't play as well as we need to."

TIP-INS

Rockets: Clint Capela returned after missing 15 games with a small left fibula fracture and started at centre. He was scoreless in nine minutes. ... The Rockets were without Ryan Anderson (flu), and Eric Gordon — bothered by a sore ankle — shot 3 for 17. ... Harden's triple-double was only the seventh posted by an opposing player in a game (including playoffs) at Miami — and the second in three weeks, after Russell Westbrook did it on Dec. 27.

Heat: It was Miami's first home game since Jan. 1. ... Okaro White was signed to a 10-day contract Tuesday, but did not play. ... Floyd Mayweather was courtside, as he's been for several Miami games this season. ... Miami held the Rockets to a 9-for-39 night from 3-point range. ... Miami's bench outscored Houston's 51-32.

TECHS FOR EVERYONE

Spoelstra received a technical early in the third quarter, upset after Rodney McGruder got hit with his fourth foul in 13 minutes. D'Antoni drew a technical with 5:40 left, and Beverley got one with 1:12 left.

HARDEN IN MIAMI

Shooting has never been easy for Harden in Miami.

He was 3 for 18 in two games at AmericanAirlines Arena in the NCAA tournament for Arizona State in 2009. He's a 38 per cent shooter in 11 games at Miami as a pro, 30 per cent from 3-point range — and his teams are 3-8 in those games.

UP NEXT

Rockets: Host Milwaukee on Wednesday, part of a four-game, five-night swing.

Heat: Host Dallas on Thursday in the second game of a four-game homestand.