SAN FRANCISCO -- Travis Shaw hit a two-out double in the seventh inning to drive in Neil Walker with the go-ahead run and the Milwaukee Brewers held on to beat the San Francisco Giants 4-3 on Tuesday night.
Ryan Braun and Keon Broxton drove in runs while Walker and Eric Sogard had two hits apiece to help the Brewers snap a five-game losing streak to the Giants.
Milwaukee trailed 3-2 following Brandon Crawford's two-run home run in the fifth before scoring twice off San Francisco reliever Albert Suarez (0-3).
Eric Thames drew a one-out walk and took third on Walker's double. Braun hit a tying sacrifice fly before Shaw lined a double just inside the first base line to drive in Walker and give the Brewers the lead.
The win pulled Milwaukee within three games of Colorado for the second NL wild card.
San Francisco missed a chance to tie the game when Milwaukee right fielder Hernan Perez threw out Nick Hundley sliding at the plate trying to score from second on Denard Span's single. The Giants also got a leadoff single in the ninth but Kelby Tomlinson was thrown out trying to steal second.
Pablo Sandoval had two hits and Buster Posey singled and scored twice for the Giants.
Jeremy Jeffress (1-0) retired three batters to get the win, his first in the National League after being acquired in a trade from Texas at the deadline. Corey Knebel pitched the ninth for his 27th save.
The Brewers scored on Broxton's RBI single in the first and tacked on an unearned run in the fourth when Gorkys Hernandez dropped Broxton's two-out fly ball at the warning track in right field.
San Francisco twice left the bases loaded before Crawford hit his 11th home run this season off Brewers starter Jimmy Nelson.
Giants: Hernandez was in the lineup after Hunter Pence was a late scratch because of a tight hamstring. Pence drew a walk as a pinch-hitter in the eighth and was replaced by a pinch-runner. . . . RHP Johnny Cueto threw 47 pitches over three scoreless innings of rehab start with Triple-A Sacramento. Cueto allowed three hits with one strikeout. 2B Joe Panik went 0 for 2 with a strikeout and played five innings in the same game.
RHP Matt Garza (6-7 4.81 ERA) makes his fifth career start against the Giants in the Wednesday afternoon series finale while San Francisco will go with LHP Matt Moore (4-12, 5.54 ERA).