HOUSTON -- The last year has been a complete turnaround for Collin McHugh.
McHugh kept that turnaround from his first major league season going Sunday.
The right-hander threw seven solid innings, and Carlos Gomez delivered a two-run, go-ahead single as the Houston Astros beat the Arizona Diamondbacks 4-1.
Dating to Aug. 1, 2014, McHugh is 20-5 with a 3.47 ERA. He was 4-17 before then, including an 0-8 record with an 8.94 ERA in stints with the Mets and Rockies from 2012-13.
"It's hard to really put into words what it came from, what my first calendar year looked like in major league baseball versus this one," McHugh said. "It has been a blessing to play on a good team like this, a good group of guys, and the organization putting faith in me the way they have to put me out there every five days."
Evan Gattis added a solo home run in the fifth to give Houston the three-run lead.
McHugh (13-5) won his fourth straight start, giving up one run and eight hits with six strikeouts.
"I think I threw a couple changeups, but for the most part, my breaking stuff was all there when I needed them," McHugh said. "We had a good game plan, and we executed it pretty well."
McHugh, who is tied for the AL lead in wins with teammate Dallas Keuchel, has allowed two runs or less in three of his last four starts.
"At one point I looked up there and he had like 15 or 16 balls of like 75 or 80 pitches," Houston manager A.J. Hinch said. "That's incredible strike-throwing. A lot of people talk about McHugh and his breaking ball, his cutter, his changeup -- he had some finish fastballs today in some really big at-bats where he reared back, had a little extra carry on his fastball and got strikeouts. Those are difficult things to do."
Pat Neshek threw a perfect eighth, and Luke Gregerson pitched the ninth for his 22nd save.
Jose Altuve and Jason Castro both had two hits for the Astros, who own an AL-best 38-18 record at home.
Gomez, who was acquired Thursday in a trade with Milwaukee, gave Houston a 3-1 lead with a two-out, two-run single in the fourth. Houston had loaded the bases on a walk to Chris Carter, a single by Castro and Altuve was hit by pitch.
"My confidence is really good," Gomez said. "I have been hitting with scoring position really well, and I walked up with an idea of `I got this.' Finally, I put a good swing and hit it the opposite way."
Jake Lamb put Arizona up 1-0 with an RBI double in the second, but Houston tied it in the bottom half on Carter's sacrifice fly.
Lamb, Welington Castillo and Nick Ahmed had two hits apiece for Arizona.
"We had situations where we should have got some runs in, but we didn't get the runs in," Arizona manager Chip Hale said. "We could have made the score a lot closer, but we just failed to do that. We have to tighten it up and play a lot better."
Robbie Ray (3-6) was tagged for four runs and seven hits with three walks and five strikeouts in five innings. Ray has allowed four or more runs in two of his last three outings -- both losses.
"It wasn't one of my best ones," Ray said. "You're not going to have your best stuff every day. I just went out there, gave it everything I had, competed and tried to keep my team in it. It's just tough when you've got guys on base and you're in those high-pressure situations all the time. Eventually, it's going to catch up to you."
COMING AND GOING
The Astros officially activated RHP Mike Fiers on Sunday after acquiring him and Gomez from Milwaukee on Thursday. Fiers will start Tuesday at Texas. ... RHP Vince Velasquez was optioned to Double-A Corpus Christi following Saturday's game to open up the roster spot for Fiers.
Diamondbacks: OF A.J. Pollock was out of the lineup for a second straight day Sunday after leaving Friday's game in the seventh inning with tightness behind his left knee. ... RHP Chase Anderson, who has been on the DL since July 19 with right triceps inflammation, was scheduled to start Sunday for the Arizona League D-backs and throw four innings or 60 pitches.
Diamondbacks: RHP Zack Godley (2-0) starts Monday in the first game of a four-game series at Washington. Godley, who has allowed three runs over his first two starts, will be opposed by RHP Doug Fister (4-6).
Astros: RHP Lance McCullers (5-3) starts Monday in the first game of a three-game series against the Texas Rangers in Arlington. McCullers has allowed three earned runs or less in 12 of his first 13 career starts. Texas will counter with RHP Colby Lewis (11-4).