In the opener of a critical four-game series between the contenders, the Giants belted four home runs to support starter Matt Cain who pitched eight innings for the win.

Cain struck out eight batters and had limited San Diego to just three hits before allowing a single then a two-run home run to Ryan Ludwick in the ninth inning.

The right-hander left the game in the ninth and improved to 11-10.

"We've had some bad times against these guys, so to win the first one is definitely big for us," Cain told reporters after getting an ovation from some of the traveling Giants fans.

"To be able to hear those guys on the road is definitely fun."

Freddy Sanchez and Huff finished with three hits each for the Giants who won for the fifth time in six games.

"They have an unbelievable lineup over there, especially with some of the moves that they've made," said Padres starter Jon Garland (13-11), who surrendered six runs and eight hits in five innings.

"They're hungry. They haven't been to the playoffs in a long time."

Two weeks ago, the Padres (79-60) held a comfortable division lead but have since suffered a 10-game losing streak to put the pursuing Giants (79-62) right back in the race.

(Reporting by Jahmal Corner in Los Angeles; Editing by John O'Brien)