Pablo Sandoval singled and Nate Schierholtz walked to open the frame. After Vizquel flied out, Velez delivered.
Pinch-hitter Fred Lewis and Rich Aurilia each singled in the bottom of the eighth inning to give the Giants a 4-2 lead.
"You look at the timely hitting," Giants manager Bruce Bochy said. "So many guys came up with big hits. We had a lot of good things happen offensively."
Keiichi Yabu allowed two hits over two scoreless innings in relief of Zito, but Brian Wilson (3-2) gave up a two-run home run to Chris Snyder in the top of the ninth to record his fourth blown save in 41 chances.
Zito received a no-decision for his six-inning effort, in which he allowed two runs on five hits, walking three and striking out nine. He's 3-1 over his last five starts with a 3.89 ERA.
"I've learned a lot of stuff this year," Zito said. "Sometimes it takes a lot of pain, a lot of struggling, to make you stronger. I'm motivated to stay within myself and not worry so much about results."
Arizona took a 2-0 lead in the second inning as D-backs starter Doug Davis and Stephen Drew each drove in a run.
Zito retired 13 of the final 16 hitters he faced following Drew's sacrifice fly.
"He's a different pitcher in the second half versus the first half," Bochy said. "He's pitching with a lot of confidence and has command of his pitches."
Zito punched a single into right to drive in the Giants' first run. Bengie Molina, pinch-hitting for Zito in the sixth, singled home Vizquel to tie the game at 2.
"It's not a pretty swing and I know it," Zito said. "For the last month and a half, I've been doing stuff in batting practice to help me hit line drives. I at least want to put it in play."
Vizquel, perhaps playing in his final games with the Giants, will return to playing regularly now that Emmanuel Burriss is out for the foreseeable future with a strained oblique muscle.
"It feels weird being on the bench, no doubt," Vizquel said. "After 18 years of playing every day, it's strange to sit around and wait for the coach to tell you to go in. It certainly gives me a different perspective on the game. I realize how fortunate we all are to play this game. I'm going to enjoy it a little more these last three weeks."
Vizquel started the eighth-inning rally with a leadoff double. He stood at the plate for a while, thinking the ball was going foul.
"I thought the ball would curve, because I hit it so high [in the strike zone]. It stayed straight. Weird, but this is San Francisco, and right field here is really mysterious."
Vizquel was impressed by how well his rookie teammates performed under the pressure of playing a team looking to make the playoffs.
"We're playing contenders right now who want to make their best pitch every time," Vizquel said. "The younger guys are doing their job. Sandoval has been amazing."
"Pablo has been great," said the former Cy Young Award winner. "He's so eager to learn, and he's a spark for this team."
Gillaspie stood around on first base for a couple of batters as a pinch-runner for Molina and became the quickest Giants player to reach the big leagues following his draft day.
"It wasn't as nerve-wracking as I thought it would be," the rookie said.
Gillaspie appeared in a Major League game 95 days after getting drafted, and 93 days after appearing in a Wichita State uniform for the final time.