After scoring first in the first two games of the series, the Giants found themselves behind early in the rubber match.
Martinez gave up a two-run double off the left-field wall to Jason Michaels with one out in the second, giving Houston a two-run lead. Michaels later came around to score the third run of the inning, never hesitating on the way to the plate on a soft ground ball hit by Kazuo Matsui, who beat out Freddy Sanchez's flip to first base, putting San Francisco behind 3-0.
A three-run deficit is something the Giants had not overcome to win since Sept. 4 at San Diego.
"You don't want to get in a hole like that, but we have been playing pretty good baseball and I was confident we were going to get some hits and score a few runs," Martinez said. "I just told myself if I could keep it there and let us get back in it, I'd be happy."
The Giants didn't waste any time starting a comeback, getting two runs back in the third by stringing together three straight singles by Randy Winn, Sanchez and Pablo Sandoval to pull within 3-2.
Sandoval, who ran into an out trying to steal second in the third, began the Giants' five-run rally in the sixth. The Giants third baseman singled off Astros starter Brian Moehler with one out and came home to tie the game on a base hit by Ryan Garko.
After a base hit by Aaron Rowand, the Astros chose to intentionally walk Edgar Renteria to load the bases for Whiteside, who promptly crushed the first pitch from Moehler over the left-field wall for his first career home run and a 7-3 Giants lead.
"It felt pretty good, especially since I haven't helped the team out offensively too much the last few games I've played," Whiteside said. "It was nice to put the barrel on the ball and help the team out with four RBIs."
Bochy had thought about pinch-hitting for his catcher with Bengie Molina, but chose to let Whiteside swing away. The decision not to make a move paid off.
With a four-run cushion, the Giants turned to their bullpen in relief of Martinez, who tossed five innings, allowing three runs and striking out four in his return to the big leagues for the first time since taking a line drive off the head April 9 against the Milwaukee Brewers.
"I was excited and nervous," Martinez said. "It had been 105 games since I pitched at this level, and it felt good to get out there. I was a little jumpy in the beginning, but after I settled down I felt great, and to get the win is even better."
The Giants would add three more runs, and five relievers combined to pitch the final four innings to preserve the victory and earn San Francisco its first road series win since June 22-24 against Oakland. It had dropped four of the last five series with one series split away from AT&T Park since then.
"I thought we had a chance even in the eighth inning to jump back into it," Astros manager Cecil Cooper said. "One big swing and we're back there or even a base hit and we could have narrowed the game or even had a chance at it, but they tack on and it makes it a little tougher."