Harden also had 12 rebounds, giving him his first triple-double of the season.
Leonard hit a step-back jumper to cut the advantage to 101-99 late in the game.
Harden then missed a three-pointer, and Leonard missed a jump shot.
Harden had the ball with 27 seconds left to try to expand the advantage. He drove into the paint but was called for a charge, giving the Spurs a final shot for the victory with five seconds remaining.
Rockets pick up the WIN in San Antonio!
— Houston Rockets (@HoustonRockets) 10 November 2016
Harden 24pts/15ast/12reb
Anderson 20pts/8reb#Rockets50 pic.twitter.com/f0pzXnH0aT