They also benefited from some strange bounces.

On Pence's double that highlighted a five-run third, his bat broke at the label on impact, then the broken barrel hit the ball twice more. That put a rolling, slicing spin on the ball and caused it to change directions -- leaving shortstop Pete Kozma little chance to make the play. Kozma broke to his right, figuring that's where the ball would go, but it instead curved to left-center.

"It was going to go in the hole and it ended up going up the middle," Kozma said.

Injured closer Brian Wilson, with that out-of-control bushy black beard, danced in the dugout and fans in the sellout crowd of 43,056 kept twirling their orange rally towels even through rain in the late innings -- a downright downpour when Romo retired Matt Holliday on a popup to Scutaro to end it.

Romo embraced catcher Buster Posey as fireworks went off over McCovey Cove beyond right field.

"It's just very fitting the way everything has gone for us this season," Romo said of ending in the rain. "The ups and downs, the injuries, the personal issues, whatever. What a ride for us all. It's very, very fitting that it rained right there."

The NL West champion Giants won their first postseason clincher at home since the 2002 NLCS, also against the Cardinals.

These 2012 Giants have a couple of pretty talented castoffs of their own not so different from that winning combination of 2010 "castoffs and misfits" as Bochy referred to his bunch -- with Scutaro right there at the top of the list this time around.

Acquired July 27 from the division rival Colorado Rockies, Scutaro hit .500 (14 for 28) with four RBIs in the NLCS. The 36-year-old journeyman infielder, playing in his second postseason and first since 2006 with Oakland, became the first player in major league history with six multihit games in an LCS.

Now, he's headed to his first World Series.

The Giants have All-Star Game MVP Melky Cabrera to thank for helping his teammates secure home-field advantage in the postseason -- while Cain was the winning pitcher the National League's 8-0 victory in July. Cabrera was suspended 50 games Aug. 15 for a positive testosterone test, then wasn't added to the roster by the Giants after his suspension ended.

After rain fell on the Cardinals during batting practice, the skies turned blue and the weather cooperated. Anxious players on both sides hung over the dugout rails as the game began.

Cain joined St. Louis' Chris Carpenter as the only pitchers with victories in two winner-take-all games in the same postseason. Carpenter, who lost Games 2 and 6 in this series, did it last year.

Cain also pitched the Giants' Game 5 division series clincher at Cincinnati, when San Francisco became the first team in major league history to come back from an 0-2 deficit in a five-game series by winning three consecutive road games.

"I think to do it, the guys actually have to believe it can happen," Posey said.

He delivered on an even bigger stage Monday as San Francisco saved its season once again. The Giants won their 20th NL pennant and reached their 19th World Series.

Cain walked off the mound to a standing ovation when Jeremy Affeldt entered with two outs in the sixth. Affeldt then got Daniel Descalso to pop out with two runners on.

Yadier Molina had four hits but got little help from the rest of the Cardinals, who went 1 for 21 with runners in scoring position over their final three games.

"It's about the team that's hot, and we went on a cold streak," Cardinals manager Mike Matheny said. "We got to this point by being that team that was hot and taking advantage of opportunities. But we just couldn't make it happen these last two games."

Cain added an RBI single to his cause and got some sparkling defense behind him.

The play of the game went to shortstop Brandon Crawford, who made a leaping catch of Kyle Lohse's liner to end the second inning with runners on second and third that would have been a run-scoring hit.

In the third, Scutaro, the second baseman, made a tough stop on a short hop by Carlos Beltran, and left fielder Gregor Blanco ran down a hard-hit ball by Allen Craig in left-center to end the inning.

Cain's second-inning single made San Francisco the first team in major league postseason history to have a starting pitcher drive in a run in three straight elimination games.

Brandon Belt hit a solo homer in the eighth for his first clout of the postseason.

It took production from everybody, even the pitchers, for these scrappy Giants to rally back from the brink one more time.

Cain certainly did his part to keep the staff rolling.

The 16-game winner, who didn't surrender an earned run during his team's title run two years ago, reached 46 pitches through two innings but settled in nicely the rest of the way to avenge a loss to Lohse in Game 3.

Cain even got to repay Holliday for his hard slide into Scutaro at second base in Game 2 here a week earlier. Cain plunked Holliday in the upper left arm leading off the sixth, drawing cheers from the crowd. After the game, Cain said that he wasn't trying to hit Holliday with the 0-2 pitch.

"Just trying to go in right there, and it got away," Cain said, according to the Sacramento Bee.

The right-hander escaped trouble in the second with runners on second and third when Crawford made his catch.

Holliday returned to the lineup after missing Game 6 a night earlier with tightness in his lower back. He received loud boos when he stepped in to hit in the first from a fan base still angry about his slide that injured Scutaro's hip.

Beltran is still left 0-fer the World Series, winless in three Game 7s during his 15-year career. And to think just last fall he was on the other side with the Giants as they missed the playoffs a year after winning the club's first World Series since moving West in 1958.

"If you look at the games we made a lot of mistakes and they didn't make any," Beltran said. "They took advantage of those. They were able to put things together, offense, pitching, defense, and we couldn't do that."

The Cardinals went an NL-best 12-4 from Sept. 16 to the end of the season to earn the NL's second wild card on the second-to-last day of the season, then won 6-3 in a winner-take-all playoff at Atlanta to reach the division series. The Cardinals then rallied from a 6-0 deficit with a four-run ninth inning to stun the Washington Nationals 9-7 in Game 5.

Sandoval's run-scoring groundout in the first that put his team ahead gave him at least one RBI in five straight postseason games, matching home run king Barry Bonds' franchise record set in 2002.

Now, Sandoval and the Giants get to play on.

"It's just surreal. The victory lap right there was the greatest thing," said Zito, left off the 2010 postseason roster for all three rounds but now a candidate to pitch Game 1. "We play best when our backs are against the wall."

Game notes

The Giants snapped an 0-5 skid in deciding Game 7s. ... The Tigers and Giants will meet for the first time in the postseason.

Information from The Associated Press was used in this report.