Tyreke Evans scored 18 points and Cousins scored 15 for the Kings.
Kevin Martin scored 30 for the Rockets, who blew an opportunity to gain ground on Memphis in the race for the eighth and final playoff spot in the West.
Houston was three games behind the Grizzlies and New Orleans entering the game, and Memphis lost to the Los Angeles Clippers.
The Rockets play in New Orleans on Wednesday night, a virtual must-win to keep their postseason chances flickering.
Kyle Lowry had 15 points and nine assists, and Luis Scola had 18 points for the Rockets, who had a seven-game home winning streak snapped.
Houston slipped to 15-6 since the All-Star break and lost for just the third time in 11 games.
"From the tipoff, we just seemed to not have our energy that we had for the last couple of months," Martin said. "It's a bad time of year to not play like you've been playing for the last couple of months. For whatever reason, we just looked really tired in a lot of spurts."
The Kings, meanwhile, have hit their stride too late in the season for it to matter. Long out of the postseason mix, Sacramento has won six of its past eight games.
"We are playing hard and together as a team," Sacramento coach Paul Westphal said. "We finally have our team together, and we like what we see. I give our players credit for their continued improvement. The players are making a statement that they care about things."
The Kings shot well and never trailed in the second half.
Thornton's fadeaway jumper with 1:26 remaining put Sacramento up 96-90, and Martin lost the ball on the Rockets' next possession, their 14th turnover.
The Kings twice fouled Lowry on 3-point tries in the final minute, and Houston's point guard went 5-of-6 from the free-throw line to give Houston a chance at the end.
But Dalembert made a pair of free throws with 11 seconds to go, grabbed a defensive rebound and made another one with five seconds left to put it out of reach.
"We lost our poise a lot during the stretch, but we didn't dwell on it," Westphal said. "Then, we still found a way to win the game."
Sacramento shot 53 percent (44-of-83) and snapped a four-game losing streak to Houston. The Kings scored 58 points in the paint and outrebounded the Rockets 46-43.
Sacramento led 52-46 after making 23 of 43 shots in the first half and outscoring Houston 34-20 in the paint. Cousins already had his 24th double-double of the season at the break, with 13 points and 12 rebounds.
Dalembert scored three baskets inside early in the third quarter to move the Kings out to a nine-point lead. Lowry made his first 3-pointer and Scola scored from the top of the key to pull Houston back within four, and Scola finished a fast break with a layup to cut the deficit to 64-62.
Thornton scored three baskets in a 40-second span as Sacramento pushed the lead to 10. The Rockets rallied again before the end of the quarter, with Lowry capping a 10-2 spurt with a running jump shot.
Houston committed four turnovers in the first five minutes of the fourth, and the Kings rebuilt a 10-point lead. The Rockets also missed seven of their first nine shots in the final quarter.
"The last month, we've been playing extremely hard," Lowry said. "When the shots didn't fall, I think the frustration got to us a little bit."
Beno Udrih hit a jumper, then drove for a layup to give Sacramento its biggest lead at 92-80 with six minutes left.
Courtney Lee and Lowry finished a 10-2 Houston run with 3-pointers, cutting the gap to 94-90 at the 2-minute mark. The Rockets had a chance to get closer, but Scola was called for an offensive foul trailing a fast break.
Cousins has nine double-doubles in his past 19 games. ... The Kings won for only the second time in their past nine trips to Houston. ... Thornton has scored 20 points or more in 10 of his past 14 games. ... Martin has reached 30 points in five of his past 12 games. ... Houston went 14-for-21 from the free throw line, after missing a total of 13 free throws over the previous five games.