James Harden netted 10 of his 25 points in the extra time as the Rockets broke a two-game home losing streak after allowing Toronto to rally from a 17-point third-quarter deficit.
Dwight Howard provided 18 points, 24 rebounds and five blocked shots.
Chandler Parsons also netted 18 points for Houston.
The Raptors were paced by Rudy Gay with 29 points and 10 rebounds before fouling out.
DeMar DeRozan put in 22 points and Kyle Lowry added 16 for Toronto.