SAN FRANCISCO -- If Matt Cain shows up at AT&T Park on Tuesday looking a little bleary-eyed, it'll probably be the result of staying up all night casting text-message or online votes for Pablo Sandoval.

Sandoval, the National League's early leader in the Final Vote competition to fill the last spot on each league's All-Star team, hit his first career grand slam to help Cain become the NL's second 10-game winner Monday as the Giants outlasted the Florida Marlins, 5-4.

Sandoval has made a habit of supporting Cain this season. The switch-hitter has delivered seven of his 13 home runs in games Cain started.

"He's been huge for me," Cain said.

This homer was the biggest. It put the Giants ahead 5-0, a cushion that enabled them to weather Florida's two runs in the sixth inning and another pair in the ninth, as Brian Wilson nearly blew his fifth save but recovered just in time to convert No. 22.

Cain called Sandoval's home run the ultimate campaign statement.

"I don't know how you could ask for anything better than that," Cain said. "I don't think there's anybody in the States who's not going to know him after tonight, especially under the voting. You need votes and you hit a grand slam first thing -- I think that's going to help you out for a couple of days."

Sandoval graciously accepted the outpouring of support. It began with his teammates wearing "Vote Pablo" stickers during batting practice, continued with frequent reminders and prompts around AT&T Park to cast ballots and ended with the curtain call that followed his grand slam.

"It's a big moment for me right now," Sandoval said.

The game's signature moment was set up for Sandoval as the Giants, who led 1-0, loaded the bases in the fifth inning on Juan Uribe's double and walks drawn by Cain and Aaron Rowand. Facing Marlins starter Sean West (3-3) with two outs, Sandoval drove a 1-0 pitch into the left-field seats.

Sandoval used reason as well as his bat. West threw him an inside fastball to induce a popup behind first base in their previous encounter during the third inning. So Sandoval figured that the Marlins left-hander would maintain his pattern.

"I was looking for the same pitch," Sandoval said.

West realized that he missed his intended location.

"I threw it right in [Sandoval's] wheelhouse," he said. "I probably should have thrown a few sliders because of the situation. He's looking for that fastball. ... I basically just gave it to him. It would have been a good pitch if it was down, but I just left it up."

Cain (10-2) lacked command of his offspeed pitches, so he and catcher Bengie Molina decided to rely primarily on fastballs.

"We were mixing it on both sides of the plate, trying to keep them off-balance," Cain said.

Cain pitched only one perfect inning, but accurate throws from left fielder Andres Torres and right fielder Nate Schierholtz apprehended Marlins runners at second base to end the third and fourth innings.

Fending off the Marlins proved crucial, given the ninth inning's events. After Jeremy Affeldt pitched typically scintillating relief for 1 1/3 innings, Cody Ross opened Florida's rally off Wilson with a one-out double. John Baker and Wes Helms singled, trimming the difference to 5-3. Wilson walked pinch-hitter Ross Gload on a 3-2 pitch to load the bases.

Chris Coghlan hit a comebacker to Wilson, who could have started an easy 1-2-3 double play by throwing home. Instead, he made a low toss toward second base, forcing out Gload but also prompting Edgar Renteria to make a one-hop throw to first base that Travis Ishikawa couldn't hold. Baker scored and the Marlins still had runners on the corners.

"I was foolish," Wilson admitted. "We all have those moments. Not everybody has them in the ninth."

Emilio Bonifacio -- the last hitter Wilson would have faced, since Sergio Romo was warming up in the bullpen -- hit another comebacker. Under the circumstances, Wilson's throw to first was entirely proper.

"I guess you get a save for that," Giants manager Bruce Bochy said dryly.