Updated

Pablo Sandoval hit a tying solo home run in the sixth inning and last-minute fill-in Mike Fontenot connected two batters later, leading the San Francisco Giants past the Los Angeles Dodgers 4-3 on Wednesday night.

Fontenot's two-out drive to the arcade in right-center off Ted Lilly (0-2) just did it for winning pitcher Jonathan Sanchez, who struck out a season-best nine in six innings. Sanchez has 24 Ks over his first three starts.

Aaron Miles had a go-ahead RBI double in the top of the sixth among his three hits for his first multihit game of 2011, but the Dodgers' 3-2 lead didn't last long.

Sanchez (1-1) remained poised after allowing a two-run homer to Rod Barajas in the fourth that tied the game at 2.

It was Barajas' third homer of the year and second in this three-game series the Giants won.

Sanchez is 5-2 with a 1.64 ERA and 72 strikeouts dating to last Aug. 30. A 13-game winner in 2010, the 28-year-old lefty is also 3-1 with a 2.10 ERA and 38 strikeouts to only six walks over his past four outings against Los Angeles.

Closer Brian Wilson pitched a perfect ninth for the second straight night for his second save in three chances. Last year's majors saves leader with 48, Wilson struck out the side in a 5-4 win Tuesday. San Francisco (6-6) has played six one-run games already, going 4-2 — all four of the wins were come-from-behind victories on this homestand.

Sandoval — back to his slugging self after a rigorous offseason in which he dropped nearly 40 pounds — and Fontenot were the catalysts with their power on a day home run king Barry Bonds was convicted across town of obstruction of justice stemming from December 2003 testimony to a grand jury that he never knowingly took steroids or performance-enhancing drugs.

Fontenot hit his first home run as a Giant after being acquired in a trade with the Chicago Cubs last August. He was added to the starting lineup just before first pitch at second base in place of Mark DeRosa, who experienced soreness in his surgically repaired left wrist and was held out as a precaution. He had been set to play for starter Freddy Sanchez, kept out to rest his surgically repaired, non-throwing left shoulder.

Fontenot's previous homer came May 7 last year for the Cubs. He also hit an RBI double in the second Wednesday for his first hit of the year, snapping an 0 for 9 start.

San Francisco took two of three in this series after the Dodgers won two of three when the teams opened the season. The Giants now hit the road for 16 of their next 19 games, beginning Friday at Arizona following an off day Thursday.

This emotional series between the longtime rivals remained pretty tame after Monday's opener began with a joint on-field message of sportsmanship, respect and nonviolence by San Francisco's Jeremy Affeldt and Jamey Carroll of the Dodgers. Longtime Giants fan Bryan Stow was severely beaten outside Dodger Stadium on March 31 after the teams' season opener and is hospitalized in Los Angeles in a medically induced coma.

Lilly did generate a warning for both benches after he hit reigning Rookie of the Year Buster Posey with pitches in the first inning and again in the third. On Tuesday night, Giants ace Tim Lincecum plunked former teammate Juan Uribe for the second time this year — a day after Uribe received his World Series ring in an on-field ceremony.

After Posey went to first in the third inning, he stole his first career base. He had one steal during the AL championship series against Atlanta last fall but it doesn't count toward his official statistics.

Lilly was booed when he stepped into the batter's box to hit in the fourth. He allowed four runs on seven hits in six innings, struck out two and didn't walk a batter.

Andre Ethier singled in the seventh for the Dodgers, giving him a 10-game hitting streak.

Casey Blake returned to Los Angeles' lineup after missing three games with a bruised thigh but played first base rather than his regular spot at third as manager Don Mattingly gave the struggling James Loney a night off.

Notes: San Francisco CF Andres Torres, nursing a strained left Achilles' tendon he hurt Saturday vs. St. Louis, hit in the cage and probably will avoid a disabled list stint if he keeps progressing. Manager Bruce Bochy said the team would make a decision Friday. With Torres out and the team short-handed, No. 5 starter Madison Bumgarner pinch-hit in the sixth. ... The Giants drew 42,060 to sell out for the sixth straight time this year and they have 16 consecutive sellouts dating back to the final regular-season series against San Diego that began Oct. 1. That includes seven postseason games. ... Dodgers RHP Vicente Padilla, who underwent surgery on his pitching elbow Feb. 24, played catch on flat ground and is slated to throw off a mound Thursday or Friday. ... Giants RF Cody Ross, on the DL with a strained right calf, did more running and is scheduled to play three innings in an extended spring training game Saturday in Arizona.