Jeremy Lin (No. 7), Dwight Howard (No. 12) and Terrence Jones (No. 6) of the Houston Rockets celebrate as time winds down in the second overtime period during the game against the Toronto Raptors. Lin scored 31 points off the bench in Rockets’ 110-104 victory. (Photo by Scott Halleran/Getty Images)

The Rockets willed their way to a win Monday night in Houston after blowing a double-digit lead in the second half against the Toronto Raptors.

Leading the way was point guard Jeremy Lin, who scored 31 points off the bench. Center Dwight Howard chipped in 18 points and 24 rebounds, helping the Rockets (5-3) win in double overtime, 110-104.

“The guys came out defensively and did a really good job,” said Houston Coach Kevin McHale, whose team snapped a two-game losing streak. “We were grinding. We just found a way to win.”

Forward Rudy Gay paced the Raptors (3-5) with 29 points and 10 rebounds, including a three-pointer that tied the game at 95 in the first overtime with 0.9 of a second remaining.

“I love the way we fought,” Raptors Coach Dwane Casey said (via the Associated Press.) “Anybody that didn’t appreciate that, we had 30 more attempts. How many times have you seen that? We just have to make shots. We only shot 25 percent in the first half, and we got back in the game with our defense.”

Lin was the star of the night, shooting 10 for 17, including three three-pointers, and hitting 8 of 9 from the free throw line in nearly 46 minutes of play.

“I started feeling pretty good and got into a rhythm [midway through the third quarter],” Lin said. “Once I got a couple of shots to go down, everything just slowed down for me.”

Lin was benched in favor of  Patrick Beverley this season but has not let it affect his play, averaging 16.1 points and four assists. His career-high season averages came during his breakout season with the Knicks in 2011-2012, where he averaged 14.6 points and 6.2  assists in 35 games.

The fourth-year guard, who has become an international sensation as the only Asian American playing in the NBA, took the demotion in stride.

“Last year, I started and there were games where I didn’t play much,” Lin said in October (via the Houston Chronicle.) “I might play the first six minutes of each half and that was it. You have to look at the game as a whole, like how many minutes you play and what you do when you are on the floor. So for me, it is not that big of a deal for me being in second unit and being able to attack and have that freedom to be able to be freelancing a bit. I think that will be fun.”

Both teams play again Wednesday night, with Houston taking on the Philadelphia 76ers (4-4) in an away game and the Raptors traveling to Memphis to face the Grizzlies (3-4.)