Matt Dominguez hit a two-run homer and a tiebreaking RBI double, and the Astros tied their season high with 17 hits as they prevented a three-game sweep.
Second baseman Jose Altuve made a pair of errors and first baseman Jon Singleton had one, with each infielder allowing a grounder through his legs.
"It's part of the game," manager Bo Porter said. "Obviously, Altuve is a guy who's pretty sure-handed, but it happens. But it's good to see the rest of the team pick those guys up."
Altuve hit a two-run homer for the Astros (41-58), who find themselves 1 1-2 games ahead of last-place Texas in the AL West.
"We battled through that game," said Dominguez, had three hits and four RBIs. "It was nice to go out there and get a win like that."
Chicago fell behind 4-0 early and tied the score 7-all in the sixth on Alexei Ramirez's RBI double, Jose Abreu's run-scoring single and a run-scoring two-out grounder by Dayan Viciedo that went Altuve's legs for Houston's second error of the inning.
Daniel Webb (5-3) allowed RBI doubles in the seventh to Dominguez and L.J. Hoes, and Marwin Gonzalez followed with a two-run single.
Tony Sipp (2-1) pitched 1-1 scoreless innings as Houston stopped a three-game skid. Josh Fields and Chad Qualls got three straight outs each.
Houston's Jarred Cosart allowed four runs, seven hits and four walks in five innings.
John Danks lasted a season-low 4 1-3 innings, giving up a season-high 12 hits and seven runs. On May 18, he allowed eight runs — seven earned — and 10 hits over 4 2-3 innings in an 8-2 loss to the Astros.
"Dug us a hole. These guys fought hard to get out of it," Danks said. "For whatever reason, Houston has beat me up this year, so fortunately, we're done with that."
Hoes filled in for Astros OF George Springer, who was held out because of soreness in his right knee and quadriceps. Springer will continue to receive treatment, and he expects be in the lineup for the opener of a three-game set against the Athletics in Oakland on Tuesday night.
"It's fine," Stringer said. "It's just a little something. I just have to make sure I'm all right, and we'll go from there. I can play through it."
NOTES: Singleton was inserted in the lineup after 1B Jesus Guzman reported back discomfort in batting practice. ... Abreu extended his hitting streak to 11 games. He had at least one hit in 29 of his last 30 games. ... Manager Robin Ventura was noncommittal about the closer role, which Jake Petricka and Zach Putnam shared in recent weeks. Matt Lindstrom (left ankle surgery) could return next month, while Thompson also was a potential candidate. Prior to the game, Thompson was recalled from Triple-A Charlotte, where he converted all six of his save chances. RHP Felipe Paulino was transferred to the 60-day DL. ... Ventura had a rooting interest in the upcoming Hall of Fame induction of Frank Thomas, his former teammate. "He was a dominant player in his era, and that will stand the test of time as far as his place with the White Sox," Ventura said. ... White Sox LHP Chris Sale is to make his first post-All-Star game start versus the Kansas City Royals on Monday night.