Updated

Aubrey Huff and Buster Posey each hit a two-run homer and Pat Burrell and Juan Uribe also went yard as the San Francisco Giants beat San Diego 7-3 Thursday night to pull within one game of the NL West-leading Padres.

Matt Cain took a three-hitter into the ninth in the opener of the four-game showdown between the rivals, who also will meet in a season-ending, three-game series at San Francisco from Oct. 1-3. San Francisco is one behind Atlanta in the wild-card race.

Cain (11-10) allowed David Eckstein's leadoff single in the ninth followed by Ryan Ludwick's homer to straightaway center, leading manager Bruce Bochy to turn to Javier Lopez and Ramon Ramirez to finish. Cain struck out eight and walked one.

It was the Giants' third win in 12 games against San Diego this season. The Giants have two more losses than the Padres, who have played two fewer games than San Francisco.

San Francisco has won eight of 11 while the Padres have lost 11 of 14. It was the 13th straight game in which the Padres were held to four or fewer runs.

Huff and Freddy Sanchez each had three hits for the Giants.

Jon Garland (13-11) took his third straight loss. His previous two defeats were during a 10-game Padres losing streak that trimmed 5½ games off their lead.

The Giants hit Garland early, often and hard. He allowed three of the Giants' homers and Kevin Correia surrendered the fourth.

Andres Torres led off the game with a triple to right-center and scored on Sanchez's single to left.

Huff's 24th homer was to the sand play area beyond the fence in right-center in the third. Sanchez was aboard on a one-out single.

Uribe also homered into the sand, on a 3-1 pitch with two outs in the fourth, for a 4-1 lead. It was his 20th.

With Huff on after a two-out double in the fifth, Posey drove a 1-0 pitch into the second deck in left for his 12th homer.

Garland was booed as he walked off the field after getting Jose Guillen to ground out. He allowed six runs and eight hits in five innings.

Correia started the sixth and gave up Burrell's towering shot off the facade of the Western Metal Supply Co. brick warehouse in the left-field corner. It was his 15th.

Ludwick's homer was his fourth with San Diego and 15th overall. Cain also allowed Will Venable's homer leading off the third, his 12th.

NOTES: The four homers tied the Giants' season high, as well as tying the Padres' season high for homers allowed. ... The Giants have won nine of Cain's starts since the All-Star break. ... Correia made his first relief appearance with the Padres after 59 starts. His last relief appearance was Sept. 24, 2008, with San Francisco. ... Correia had been scheduled to start Tuesday but was pushed back when illness pushed back ace Mat Latos from Monday to Tuesday. ... Friday night's pitching matchup is San Francisco's Jonathan Sanchez versus San Diego's Clayton Richard.