PHOENIX (AP) " The Arizona Diamondbacks have been waiting for a big hit all season.
They got two on Sunday.
Justin Upton hit a tying two-run homer in the ninth inning and Conor Jackson hit a bases-loaded single in the 12th as the Diamondbacks rallied for a 5-4 victory over the San Francisco Giants.
"It took a while, (but) we got some big hits," Arizona manager Bob Melvin said. "It was setting up to be the same type of game where we just couldn't get big hits when we needed to, even though we did hit some balls hard. You keep fighting."
As the Diamondbacks streamed out of their dugout and mobbed Jackson, it looked as if they had clinched a division title. In reality, they had salvaged the finale of a three-game series on a sunny, 83-degree day.
They hope this dramatic victory will energize them after a disappointing 7-11 start " including 6-9 at home.
"Baseball's just a vicious game," Jackson said. "You go through cycles. You're going to go through ups. You're going to go through downs. Hopefully, this will carry over some momentum."
Juan Gutierrez (1-1) pitched the 12th for the Diamondbacks.
The winning rally began when former Diamondbacks reliever Brandon Medders (0-1) walked leadoff man Miguel Montero. After a sacrifice bunt, Medders walked Felipe Lopez intentionally and Augie Ojeda unintentionally to load the bases.
San Francisco manager Bruce Bochy summoned Justin Miller, who gave up a line drive single to Jackson to deep left field.
Arizona entered the ninth down 4-1 and facing Wilson, who had three saves in his first three chances against the Diamondbacks. Wilson soon had his first blown save.
Chad Tracy bounced an 0-2 pitch down the right-field line for a leadoff double, and Mark Reynolds singled to make it 4-2.
Reynolds was erased on Eric Byrnes' fielder's choice grounder. That brought up Upton, who hit a 3-1 pitch into the left field bleachers to tie it 4-all.
Upton was looking for a fastball all the way, and the hard-throwing Wilson delivered it.
"I don't think you're ever looking for a home run," Upton said. "I was looking to extend the inning."
Upton entered hitting .190 with one homer and three RBIs, and there has been speculation that the Diamondbacks might ship the 21-year-old outfielder to the minors. The talk will likely subside after he went 2-for-3 and walked twice.
"You can see the confidence grow more than anything," Melvin said. "For a guy that has the type of talent that he does, all it takes is a few at-bats and some confidence, and you let your ability come out."
Wilson said he had trouble commanding his fastball but added that he wasn't tired.
"I don't make excuses," Wilson said. "Fatigue is not something that enters my body. I just wasn't able to locate."
The Giants thought they had won it in the eighth, when Pablo Sandoval hit a three-run homer, one of his career-high four hits.
Sandoval singled in the first and fourth innings and added a double in the sixth. But his biggest blow came with two on in the eighth against Arizona starter Jon Garland.
"We got the hit we were looking for all day," Bochy said. "We just couldn't hold it." Notes: San Francisco LHP Barry Zito will go for his first win, in his fourth start, on Monday against the Dodgers. Zito is 0-2 with a 5.63 ERA. ... Arizona RHP Esmerling Vasquez made his major league debut after being called up from Triple-A Reno earlier in the day. Vasquez gave up a single to Emmanuel Burriss on his first pitch, then picked Burriss off first one out later. ... The Diamondbacks have played 18 games. They'll try to win consecutive games for the first time on Monday against the Chicago Cubs.