HOUSTON -- After the Houston Rockets snapped a three-game skid with a 112-109 win over the Toronto Raptors on Friday night, James Harden was asked if he felt they had to win the game.

There was no hesitation in his reply.

"We've got to win every game from here on out," Harden said. "We've only got a handful left so each and every game is important. We've got to take advantage of opportunities."

More from FoxSports

Harden had his third triple-double this season with 32 points, 13 assists and 11 rebounds to help the Rockets to the victory, which moved them into seventh place in the Western Conference standings with nine games left in the regular season.

Houston squandered a double-digit lead early but opened the fourth quarter with a big run to take control.

"We got a big lead so we kind of got relaxed, turning the ball over, taking a few bad shots and we had to slow down a little and get back to what we're doing and what got us the lead," Harden said.

Patrick Patterson scored five quick points to get Toronto within 110-107 with 10.1 seconds remaining, but Trevor Ariza made two free throws after that to secure the win.

It's Toronto's second straight loss overall and its ninth loss in a row in Houston, where the Raptors haven't won since 2007.

In the last few minutes, Toronto stars DeMar DeRozan and Kyle Lowry both get ejected for arguing with the officials.

DeRozan scored 18 points before being kicked out with about 3 minutes left. He made a layup that cut the lead to 103-97 but was unhappy that a foul wasn't called on the play and began yelling at the officials. He was quickly given a technical but kept jawing and was given a second one and ejected from the game.

"I just thought I got pushed," DeRozan said. "I didn't think I was going to get a second (technical) ... but he called it and I have to deal with it."

The Rockets scored four of the next six points, with three from Michael Beasley, to make it 107-99.

Lowry was ejected with 25.6 seconds left when he got his second technical of the game for arguing with officials.

"We got back into the game but at the end we just weren't there defensively," Lowry said. "I personally didn't play well at all."

Lowry missed Wednesday's game with a sore right elbow. In this one, he had 15 points with three 3-pointers to set a franchise record for 3s in a season with 192. Lowry now has the top two 3-point performances in franchise history after making 190 in 2013-14.

Houston started the fourth quarter on a 13-2 run to extend a one-point lead to 92-80 with about 9 minutes remaining. Harden and Jason Terry made 3-pointers in that stretch, but it was Corey Brewer who wowed the crowd when he made a layup as he was being pulled down from behind by James Johnson and then finished the three-point play.

The Raptors got back on track after that, using a 7-1 spurt to cut the lead to 93-87.

Toronto cut the lead to four before Houston scored the next five points, with a 3-pointer by Ariza, to make it 100-91 with about 5 minutes left.

Houston capped the third quarter with a 7-1 run, with the last four points from Harden, to take a 79-78 lead into the fourth.

The Raptors were down by 11 in the second quarter before scoring 15 straight points to take a 48-44 lead just over 3 minutes before halftime. Former Rocket Luis Scola led the way in that stretch, scoring eight points, with a pair of 3-pointers.

Houston missed seven shots, including two on blocks by Bismack Biyombo, and committed three turnovers to allow the Raptors to take the lead.

TIP-INS

Raptors: Lowry's first technical came in the first quarter. ... Patterson had 11 points in his return after missing two games with a sore left ankle. ... Scola had 16 points. ... Jonas Valanciunas had 16 points and 18 rebounds.

Rockets: It is the ninth triple-double of Harden's career. ... Patrick Beverley tied a season high with five 3-pointers. ... Brewer had 10 points.

FITTING IN NICELY

Beasley, who spent most of this season playing in China, has fit in nicely in Houston since joining the team on March 5. He had 21 points on Friday to give him at least 10 points in nine straight games.

"He's been playing very well," Harden said. "Short amount of time he's been here he's been really aggressive offensively."

UP NEXT

Raptors: Visit New Orleans on Saturday night.

Rockets: Visit Pacers on Sunday night.