DENVER (AP) -- With the bases loaded, the count full and the game on the line in extra innings, Chad Bettis had no wiggle room for a breaking ball or an off-speed pitch.
He had to rely on his fastball, and he knew it.
So did Hector Sanchez.
Sanchez hit two of San Francisco's six home runs, including an 11th-inning grand slam off Bettis, and the Giants hung on to beat the Colorado Rockies 12-10 on Wednesday.
Sanchez, the Giants' backup catcher, also had a solo home run in the eighth and finished with a career-high five RBIs.
With the score tied at 8-all and the Rockies trying to complete a series sweep of the Giants at Coors Field for the first time in 12 years, Sanchez drove a fastball from Bettis (0-1) over the wall in center.
"Once I got to 3-2, just trying to fill up the zone," Bettis said. "I had nowhere to put him. He kept fouling off until he got a pitch he could hit. From my standpoint, threw too many (fastballs). I put myself in a bad spot and got hurt for it."
Rockies manager Walt Weiss said that Sanchez, whose slam came at the end of a 10-pitch at-bat, was able to draw a bead on Bettis' pitching because of the long plate appearance.
"That at-bat got extended against Sanchez, a 3-2 count, he ended up getting him timed up pretty well," Weiss said. "Pretty much banking he was going to get a fastball at that point."
Michael Morse also hit two homers -- a solo shot in the second and a three-run homer the following inning -- as two Giants hit multiple homers in the same game for the first time since May 25, 2005. Brandon Hicks and Brandon Belt also went deep as the Giants rallied from a 5-1, second-inning deficit.
Jean Machi (4-0) got one out in the 10th for the win. Sergio Romo struggled in a non-save situation, allowing a two-run homer to Justin Morneau, but retiring Brandon Barnes on a game-ending 5-4-3 double play.
Hunter Pence led off the 11th with a single and Belt followed with a walk. After a sacrifice, Joaquin Arias was intentionally walked to get to Sanchez, who delivered his first career slam.
Sanchez sent the first pitch from reliever Matt Belisle into the second deck to give the Giants an 8-7 lead in the eighth.
But the Rockies tied it in the bottom half when D.J. LeMahieu singled and was bunted over to second. He went to third on a balk by Santiago Casilla and scored on Charlie Blackmon's sharp grounder to Hicks, who couldn't field it cleanly to make a play at home.
Despite the loss, the Rockies completed a 4-2 homestand, taking the series against Giants and Philadelphia Phillies.
"That's the way we've got to look at it," Weiss said. "Would've loved to have gotten that game. We had (Giants starter Matt) Cain on the ropes early, but we've seen him do that before, where he battles and competes and somehow finds a way to stick around until late in the game. He's done that a handful of times against us.
Cain allowed seven runs, 10 hits and three walks in six innings and is 0-3 with a 4.35 ERA in five starts.
Blackmon finished 2 for 5 with a homer and four runs -- lowering his batting average to .410. Troy Tulowitzki added a two-run homer and Nolan Arenado extended his hitting streak to 14 games with an RBI double in the seventh.
Belt's two-run homer in the seventh gave the Giants a 7-6 lead and came off Rex Brothers. The hard-throwing lefty allowed a game-ending, 10th-inning homer to Brandon Crawford on April 13.
Arenado tied the game with an RBI double off Cain. With two on and no outs, reliever Jeremy Affeldt was summoned into the game and got the Giants out of trouble.
Giants manager Bruce Bochy tinkered with his starting lineup, resting catcher Buster Posey and outfielder Angel Pagan, who been bothered by knee soreness. Pagan entered as a pinch hitter in the eighth and grounded out. Posey was intentionally walked in the 10th.
Bochy said Pagan will have his knee checked out Thursday in San Francisco.
NOTES: Bochy was ejected in the fourth inning by plate umpire Chris Conroy, Bochy's first ejection this season. ... The Giants and Rockies are both off Thursday. ... Hicks had to stop at second on his double in the eighth when a fan reached over the railing to grab it. The Giants and Rockies are tied 3-3 in their season series, with 13 games left between the NL West rivals.