SAN FRANCISCO -- Jason Kubel squandered three chances for a big hit that could have helped the Diamondbacks avoid extra innings. Given a fourth opportunity, he finally came through.
Kubel, who leads the team with 82 RBIs, struck out with two runners on in the first and third. Then he fouled out with the bases loaded to end the eighth. But in the 11th, he delivered at last.
"I had a chance to do that earlier and missed it," Kubel said. "I'm glad I was able to do that when I did. It was a fun game. Well, not so much fun -- but we won the game and that's all that matters."
The first-place Giants used 11 pitchers, matching a major league record for extra-inning games. They remained 4 1/2 games ahead of Los Angeles in the NL West because the Dodgers also lost at home in 11 innings, to San Diego.
Hill drove in two runs and was a triple shy of his third cycle this season. John McDonald also had two RBIs for the Diamondbacks, who ended a three-game skid.
"There's something special about this team that we kept fighting no matter what the situation," Belt said. "I can't say enough about what everybody in here is doing."
Josh Collmenter (4-3) pitched two innings for the win.
Hill opened the 11th with a single off George Kontos (1-1) and scored on Kubel's one-out triple to right-center off Javier Lopez. After an intentional walk to Paul Goldschmidt, Miguel Montero added an RBI single.
"It was a great game," Diamondbacks manager Kirk Gibson said. "We had the lead and we were in command and the Giants did, really, what they've been doing all year and kept coming back. We kept our composure and it was a good win for us."
Kennedy was charged with five runs and seven hits over 5 2/3 innings. He walked one and struck out five.
"We got down and came back against a guy who's been tough on us," Giants manager Bruce Bochy said. "We couldn't quite finish it. The guys did a great job of swinging the bats and the bullpen did a great job of keeping us in it."
Giants starter Ryan Vogelsong lasted 3 1/3 innings, allowing six runs on nine hits. He walked two and struck out seven.
After pitching at least six innings in his first 21 starts, Vogelsong has failed to get out of the fourth in three of the past five. He has a 10.13 ERA during that span, giving up 24 runs and 37 hits in 21 1/3 innings.
Sandoval followed Marco Scutaro's first-inning triple with a groundout to put the Giants ahead 1-0.
The Diamondbacks tied it on Kennedy's RBI single in the second and took the lead in the third when Goldschmidt doubled home a run and McDonald singled home two more.
The Giants got one back when Scutaro doubled in the third.
Hill's two-run homer in the fourth put Arizona ahead 6-2 and ended Vogelsong's night.
Hunter Pence doubled home a run and scored on Belt's two-run homer in the sixth to cut it to 6-5. Sandoval singled home a run in the seventh to tie it.
CF Adam Eaton had two hits in his major league debut with the Diamondbacks after having his contract purchased by the club earlier in the day. C Henry Blanco was transferred to the 60-day disabled list to make room for Eaton on the 40-man roster. ... Giants broadcasters Mike Krukow and Duane Kuiper called the game from center field. The game-time temperature was 57 degrees, with the wind blowing out to center. ... Kennedy recorded his first no-decision in 11 starts. ... Pence had two assists from right field. ... The Giants added INF Emmanuel Burriss, RHP Dan Otero and LHP Dan Runzler to the roster. RHP Eric Hacker was designated for assignment to make room for Burriss on the 40-man roster. ... RHP Trevor Cahill (9-11, 3.99 ERA) starts for the Diamondbacks on Wednesday. He is 0-2 against the Giants this year but 3-2 overall. LHP Madison Bumgarner (14-9, 3.07) goes for the Giants. He is 0-2 against Arizona this year and 3-2 overall.