SAN FRANCISCO -- Hunter Pence, promoted to third in a new-look batting order, walked and eventually scored the tiebreaking run in the eighth inning of the San Francisco Giants' 4-2 victory over the Milwaukee Brewers on Monday night.
Jeff Francoeur's pinch single broke a 1-1 tie and triggered a three-run, eighth-inning rally.
The win was the 50th of the season for the Giants, who lost seven of their previous eight home games. The defending World Series champs were just the 11th team in the National League to reach the 50-win milestone this season.
Pence, who had batted fifth or sixth most of the season, got the difference-making uprising going by drawing his third walk off the night off John Axford (5-5). The Brewers reliever faced only three Giants and walked two of them, one intentionally.
After Pence stole his second base of the night, the Brewers elected to walk Pablo Sandoval intentionally and bring in left-hander Michael Gonzalez to face left-handed-hitting Brandon Belt. The Giants first baseman drew a walk to load the bases and set the stage for Francoeur.
Brewers right-hander Rob Wooten was brought on to face Francoeur, but fell behind 2-0 before serving up the tiebreaking hit, a softly struck flare over shortstop Jean Segura's head.
With two outs and the bases loaded, pinch hitter Joaquin Arias hit a groundball through Brewers third baseman Jeff Bianchi for a two-run error that broke the game open.
Santiago Casilla (5-2), the third Giants pitcher, got the win after pitching a scoreless eighth inning. Sergio Romo recorded his 27th save despite serving up Juan Francisco's 15th home run, a one-out solo shot in the ninth.
The win was the first of the season for the Giants over the Brewers, who had swept a three-game series against San Francisco in April.
The Brewers, who were opening a 10-day, nine-game road trip, tied the game at 1-1 in the seventh inning on a ground-rule double by Francisco that scored Jonathan Lucroy, who opened the inning with a double.
Left-hander Javier Lopez relieved Giants starter Chad Gaudin later in the inning with the bases loaded and one out, and he got pinch hitter Rickie Weeks to ground into an inning-ending double play.
Neither starting pitcher factored in the decision.
Gaudin allowed one run or none for the sixth time in his past seven starts. He allowed four hits, one run and four walks in 6 1/3 innings, striking out eight.
Brewers starter Tyler Thornburg, who was 0-9 at Triple-A Nashville this season, continued his improbable major league success story by holding the Giants to one run, who was unearned, in six innings. The 24-year-old right-hander has not allowed an earned run in either start for Milwaukee this season, and he lowered his overall ERA in eight appearances to 1.78.
The lone run he allowed was the product of a throwing error by first baseman Francisco in the fourth inning. Thornburg allowed seven hits in his six innings. He walked two and struck out four.
The Giants broke a scoreless tie in the fourth inning but failed to do bigger things after a promising start.
NOTES: Giants third base coach Tim Flannery joined his brother, Tom, and guitarist Bob Weir to sing the national anthem on Grateful Dead Tribute Night. Former NBA star and longtime Grateful Dead supporter Bill Walton threw a ceremonial first pitch. ... The Giants announced before the game RHP Ryan Vogelsong would return from the disabled list to start Friday's series opener against Baltimore. Vogelsong hasn't pitched in the majors since breaking bones in and below his right pinkie finger while batting May 20. ... Injured 3B Aramis Ramirez made the 10-day, nine-game road trip with the Brewers and is expected to be activated from the DL in time to serve as the club's designated hitter in Seattle and Texas. ... Brewers 20-year-old LHP William West was suspended for 50 games for a second violation of baseball's minor league drug policy. The violation was not connected with the Biogenesis investigation. West had been pitching in the rookie-level Arizona League.