De'Aaron Fox added 27 points and eight assists for Sacramento. Buddy Hield scored 19 points and Harrison Barnes had 16 points and nine rebounds.
Christian Wood had 26 points for Houston. Jae'Sean Tate added 17 points, 10 rebounds and eight assists. The Rockets have lost 16 of 20.
The teams play each other again on Sunday.
Bagley had his best game of the season and was strong down the stretch, scoring 10 points in the fourth quarter while helping Sacramento to its second straight win.
"I'm just trying to stay locked in on what we're doing," Bagley said. "I'm showing up every day with a good mindset, trying to keep my body healthy and stay positive and play as hard as I possibly can every time I step out there. I'm just happy I'm able to come in and contribute to the team winning."
The second overall pick in 2018, whose minutes have gone up significantly since interim coach Alvin Gentry took over when Luke Walton was fired in November, was 12 of 20 from the floor.
"He did a really good job of finding open spots when we drove the basketball," Gentry said. "Even when we drove it baseline, he just found those open holes in the defense and was able to finish at the basket. We need that kind of play out of him."
Sacramento led 98-91, then scored 12 straight. Houston responded with a quick flurry of 3-pointers and got within 110-103 before Bagley made a pair of free throws, Hield sank two and Bagley scored on a spinning one-hander in the lane.
The Rockets got to 118-111 but Barnes made a short runner and Tyrese Haliburton made two free throws.
"In the halfcourt they make it hard on you," Rockets coach Stephen Silas said. "Fox is tough. He was driving, making shots. Bagley with his offensive rebounds and in the paint, those 8-foot shots. Those hurt us."
Wood had 15 points in the first 7 minutes of the game and helped the Rockets build an early 11-point lead. But he spent much of the first half on the bench after picking up his third foul with 4:14 left in the first quarter.
Sacramento took advantage while Wood sat. The Kings tied it late in the second on Hield's 3 and closed the quarter on a 10-2 run to go up 65-60.
KEEPING THEIR GUARDS UP
The Kings closed the third period with five guards on the court: Fox, Haliburton, Hield, Terence Davis and Davion Mitchell.
Rockets: Houston is 10-5 when leading by 10 or more. ... The Rockets scored 40 points in the first quarter. ... First-round pick Alperen Sengun had nine points and four rebounds in 14 minutes in his return after missing seven games with a right ankle sprain. ... Daniel Theis was given a technical after being called for an offensive foul in the second quarter.
Kings: Sacramento's 126 points were its most since scoring a season-high 142 against Orlando on Dec. 8. ... Bagley's double-double is his fourth this season. ... Damian Jones has cleared the NBA's health and safety protocols and joined Richaun Holmes in conditioning workouts. ... Tristan Thompson (non-COVID illness) remains out.
The two teams meet for the second time in three days when they play at Golden 1 Center on Sunday afternoon. They'll do the same thing in Houston on March 30 and April 1.