Houston took advantage of a mental mistake by New York's J.R. Smith, who despite the fact the shot clock had been turned off chose to launch a 3-pointer with 20 seconds to play in a tie game.
Brooks grabbed the rebound, was fouled and he came through at the line to give the Rockets the lead. Both Iman Shumpert and Beno Udrih missed attempts to tie the game in the final 10 seconds.
The Rockets trailed by eight points heading into the final period, but rallied to defeat the Knicks for the 17th time in 18 meetings.
Shumpert scored 26 points, hitting all six of his 3-point tries. Carmelo Anthony added 25 for the Knicks.