Eric Chavez’s first hit since coming off the disabled list Monday couldn’t have come at a better time. With two on and no outs in the ninth of a tie game Chavez looped a game-winning single to left-center to give the Diamondbacks a 4-3 win over the San Francisco Giants in front of 36091 at Chase Field on Saturday.

“Chavvy has been struggling a bit since he came back” Diamondbacks manager Kirk Gibson said. “He told me in BP ‘My swing just stinks right now.’ I said ‘It’s going to wake up tonight at the right time.’”

The win allowed Arizona to remain six games back of Cincinnati in race for the final NL Wild Card spot.

Willie Bloomquist led off the ninth with a single and moved to second on Adam Eaton’s sacrifice bunt. The Chase Field crowd roared as first baseman Paul Goldschmidt came to the plate but the Giants opted to walk Goldschmidt to get to Chavez who was 0 for 4 with a strikeout at that point in the game.

“You have to walk him there” Chavez said. “(The Giants) have been burned before. He’s had some big late in games against them.”

Chavez smacked a ball to the gap in left-center that would have been a double were he not met by a celebratory mob after reaching first.

The Diamondbacks took an early lead scoring three runs in the fourth but starter Trevor Cahill ran out of gas in the seventh giving up three runs to tie the game.

Cahill’s night: For the first six innings of his outing Diamondbacks starter Trevor Cahill kept getting into jams and kept getting out of them.

In the first he left the bases loaded by getting Pablo Sandoval to fly out. In the fourth he stranded runners on first and second by getting Gregor Blanco to ground into a double play. He left a runner at third in both the fifth and sixth ending the latter by freezing Brandon Crawford with a called third strike.

“In the first inning I put some guys on and was able to get out of it” Cahill said. “I kind of calmed down after that and made some big pitches when I had to.”

In the seventh things caught up to Cahill. Gregor Blanco led off the inning with a solo home run to left field just his second of the season. Angel Pagan followed with a one-out single and then scored on Marco Scutaro’s triple to end Cahill’s night.

Cahill finished giving up three runs nine hits and three walks in 6 1/3 innings. He struck out three but is still searching for consistency with his arm slot.