Updated

Arizona's Daniel Hudson matched his career high with 10 strikeouts but he was no match for the crafty pitcher for the San Francisco Giants.

Matt Cain, picking up where he left off in a superb postseason, had his third straight strong outing this season and Pablo Sandoval hit a three-run homer in the first inning to lift the San Francisco Giants to their third straight victory, 5-2 over the Arizona Diamondbacks on Friday night.

Hudson (0-3) allowed five runs, four earned, on six hits. He walked three.

"I thought I threw really well," the 24-year-old right-hander said. "I really only want one pitch back, and that is the one Sandoval hit. It was a changeup right over the plate."

That gave the Giants all the lead he needed.

Cain (2-0) allowed one run on four hits in six innings — plus two batters. The Giants' right-hander, coming off a superb postseason, threw six scoreless innings, then gave up a popup double down the right field line to Stephen Drew and hit Melvin Mora to end his night in the seventh. Drew later scored, just the third run charged to Cain in 19-plus innings this season.

"He's really, I think, grown so much over the past year and a half," manager Bruce Bochy said of the pitcher, who he believes now ranks among the best in the National League. "He's carried what he did in the postseason to this year, that's mixing up pitches, quality strikes. He's got a good change-up going and good poise out there."

Cain threw 21 1-3 innings without allowing an earned run in the Giants' postseason run to the World Series title.

Hudson (0-3) has had just one run of support in his three outings.

"He has thrown good games for us and has nothing to show for it," Arizona manager Kirk Gibson said. "On the other end we were 1 for 7 with runners in scoring position. We didn't take advantage of our situations."

Brian Wilson came on with runners at first and second and two outs in the ninth. He gave up an RBI single to Willie Bloomquist before getting slumping Kelly Johnson to pop out for his third save in four tries.

With one out in the first, Freddy Sanchez singled off the glove of third baseman Melvin Mora, then Buster Posey singled up the middle to bring up Sandoval. With two outs, on a 1-0 pitch, the still big — but not as big as before after an offseason conditioning program — hit a towering shot over the swimming pool in right field to put the Giants up 3-0.

San Francisco added one in the fourth when Sandoval drew a leadoff walk, Brandon Belt singled and Tejada doubled down the left field line. Cain followed with a low liner to right fielder Justin Upton, who made the catch and threw home as Belt was held at third. Upton had two singles off Cain.

The Giants scored an unearned run in the fifth. After Aubrey Huff walked and Posey singled, San Francisco went with a double-steal. Catcher Miguel Montero threw wild to third allowing a runner to score and make it 5-0.

After Cain departed in the seventh, left-hander Jeremy Affeldt fanned Montero but walked pinch-hitter Xavier Nagy to load the bases. Bloomquist's RBI sacrifice fly off reliever Ramon Ramirez ended the shutout.

NOTES: Giants RHP Tim Lincecum is donating $25,000 to the Bryan Stow Fund to benefit the San Francisco fan critically injured in an attack following the season opener at Dodger Stadium on March 31. ... Bloomquist stole his seventh base of the season. ... Hudson got his third hit in five at-bats. ... Johnson robbed Sanchez of a hit with a sliding catch behind first base to start the fifth. ... Johnson was 0 for 5 to fall to .157 for the season. ... The Giants lead all NL West teams with 151 home runs at Chase Field.