Gonzalez (3-2) gave up one run on five hits and a walk with seven strikeouts for his first win since April 23.
Chris Davis singled to lead off the fourth for the Orioles and then scored on an Adam Jones double to left center. Jones went to third on a groundout by Matt Wieters and scored on a single by J.J. Hardy.
Chris Dickerson reached on a fielder's choice, advanced to third on a single by Ryan Flaherty, and then scored on a wild pitch by Bud Norris (5-5), who allowed three runs on nine hits and one walk, with seven strikeouts in a seven-inning start for Houston.
Brandon Barnes scored for the Astros on a first-inning sacrifice fly by J.D. Martinez.