The Giants delivered an admirable effort through most of the evening, backing Matt Cain's typically stout pitching with breathtaking defense. Yet they fell behind the Major Leagues' worst team in the eighth inning as Jimmy Paredes scored on Cain's wild pitch to break a 1-1 tie.
Then Brandon Belt, batting only .213 against left-handers, singled up the middle to open the Giants' ninth against Astros southpaw Wesley Wright.
Wilton Lopez (5-3) relieved Wright and yielded a double to Arias, who drilled the first pitch he saw past third base. The ball rattled around the left-field corner, enabling Belt to score with third-base coach Tim Flannery virtually escorting him toward home.
"That's one of our biggest hits this year," Bochy said.
One out later, Sanchez blooped a 1-1 changeup into center field for a single, scoring Arias.
"I broke my bat, but I hit it in a good spot," Sanchez said.
Sergio Romo threw only seven pitches in a perfect ninth inning to preserve the decision for Santiago Casilla (5-5), who recorded the final two outs in the eighth.
"They went up there swinging," Romo said of the Astros' hitters. "That kind of helped me out, I guess."
Said Astros manager Tony DeFrancesco after his club fell to 1-6 against the Giants this year, "I'm a little disappointed. We had the chance to win the game there in the ninth inning. You've got to remember we're going against a pretty good team."
The Giants (72-57) moved a season-high 3 1/2 games ahead of the second-place Dodgers in the West standings.
"I think it's going to build a lot of momentum for us for the week," Cain said of San Francisco's eighth win in 11 games.
Facing the team that began the game with the NL's second-worst ERA (4.74), the Giants mustered six hits through eight innings and scored only on Angel Pagan's two-out homer off Houston starter Bud Norris in the fifth. Fernando Martinez countered for Houston with a leadoff homer off Cain in the bottom of the fifth.
Unable to sustain offense against Astros starter Bud Norris, the Giants backed Cain defensively.
Shortstop Brandon Crawford dove to snare Jason Castro's first-inning foul popup after third baseman Pablo Sandoval couldn't make the catch but kept the play alive by batting the ball into the air. Sandoval made a deft backhanded stop of Jose Altuve's grounder to end the third, center fielder Pagan saved a run by lunging to grab Tyler Greene's fourth-inning liner and Crawford made a nice over-the-shoulder catch of Paredes' bloop in short left field to open the sixth.
"I felt like a wide receiver," Crawford said, wryly noting that left fielder Gregor Blanco collided with him like a safety while they pursued Pagan's fourth-inning relay.
"Those guys have done a great job all year for me, picking me up and making spectacular plays behind me," said Cain, who waited by the dugout steps to congratulate Pagan after his gem. "As a pitcher, that motivates you to keep wanting to go back out there to pitch well. You've got guys behind you who are pushing to win games any way they can, putting their bodies on the line. That's always an effort you appreciate as a pitcher."
Cain, who owns a 1.19 ERA in three starts this season against Houston, also helped himself. After his awry pickoff throw left Marwin Gonzalez on third with nobody out in the fifth, he stranded the runner by coaxing three consecutive ground balls. Brett Wallace and Castro singled with one out in the sixth before Cain recovered by striking out Greene on a curveball and Martinez with a fastball.