"He was making some mistakes, falling behind hitters and walked three guys," Martinez said. "I knew he had to give me something to hit. That was my mindset. I was going to be aggressive and go for it."
Matt Downs also homered and Justin Maxwell drove in a run for the Astros, who dropped 13 of their previous 17 games -- including a 10-0 loss Wednesday night when Giants ace Matt Cain pitched a perfect game.
Jose Altuve had two hits and a walk. The young second baseman ranks among the major league leaders in average and hits.
"We had to bounce back today and we had to get runs early," Downs said. "Altuve set the tone early and got it over with. That pumped all of us up."
"He was able to give us a quality start," manager Brad Mills said. "That two-out home run was a little bit of a hiccup but, it's always nice to get at least one game in the series."
Zito (5-4) lasted five innings, allowing five runs and five hits. He walked three and struck out three in losing two straight decisions for the first time this season.
"I screwed up making pitches and things happened after that," Zito said.
After tossing 8 1/3 shutout innings against the Chicago Cubs on June 3, Zito has allowed nine runs and 14 hits in his last 11 innings.
"He was throwing the ball well," Giants manager Bruce Bochy said. "He allowed a solo home run and then got out of sync."
Downs gave the Astros a 1-0 lead with his fourth homer of the season with two outs in the second.
Zito walked Altuve, Brian Bixler and Jed Lowrie in succession to open the third, setting up Martinez's slam that traveled halfway up the left-field bleachers. The left-hander has allowed four home runs in his past two games after giving up four in his previous eight.
"I was relieved I was able to come through for the team," Martinez said. "We kept telling each other to attack them early and score early."
Maxwell's two-out single in the eighth gave the Astros a 6-3 lead.
Belt's third home run in three days put the Giants on the scoreboard in the fourth. His two-run shot cleared the right-field bleachers and landed in McCovey Cove.
Sanchez hit his sacrifice fly in the sixth.
Giants 1B Aubrey Huff underwent an MRI to assess damage in his bruised right knee, injured when he jumped over the dugout railing after Cain's perfect game. ... Martinez has 13 RBIs in 10 games against the Giants. ... Astros slugger Carlos Lee was slated to start a rehab assignment with Double-A Corpus Christi. ... The Astros have signed 26 of their 41 draft picks, including 15 of the first 21. ... Giants INF Joaquin Arias extended his career-best hitting streak to eight games. ... Altuve recorded his 28th multihit game. ... Martinez hit two grand slams in Double-A last year.