Updated

MILWAUKEE -- Chase Anderson pitched 7 2-3 shutout innings, drove in a run and won his third straight game, Hernn Prez homered and the Milwaukee Brewers beat the San Francisco Giants 5-2 on Tuesday night.

Anderson (5-1) extended his scoreless streak to 21 2-3 innings with the win. He walked one, struck out four and helped the Brewers beat the Giants for just the third time in the last 17 games against them.

Anderson kept his shutout going by stranding Brandon Crawford at third in the fifth. Anderson escaped the sixth when Brandon Belt grounded out to first with runners at first and second and two outs. The Brewers turned three double plays for Anderson.

Anderson collected his first RBI of the season and the fifth of his career in the third with a double off the wall in left.

The fans let Brewers reliever Carlos Torres hear it after he gave up three straight singles and two runs in the ninth. Buster Posey drove in a run before Torres' throwing error trying to start a double play allowed another run in. Corey Knebel came on with runners at first and second, no outs and retired three straight for his sixth save.

The Brewers roughed up Matt Cain (3-5) with four runs in the second, highlighted by a solo home run from Prez and Eric Sogard's two-run bloop double into short left field. Domingo Santana capped it with an RBI single.

Cain allowed 10 hits, two walks and struck out three over five innings. It was his fourth straight loss. He hasn't won on the road since his 7-1 win on Aug. 6 at Washington, a span of eight road starts.

The Brewers challenged a safe call at first in the sixth. After a 1:37 review, the call was overturned.

TRAINER'S ROOM

Giants: OF Hunter Pence (left hamstring strain) made his second consecutive start since coming off the DL on Sunday. . OF Jarrett Parker is getting closer to a minor-league rehab assignment. He is on the 60-day DL with a fractured right clavicle. The Giants plan to re-evaluate him after the current trip.

Brewers: RHP Matt Garza threw a bullpen session and is expected to make his next start Thursday in the series finale against the Giants. He left his start Saturday after four innings following a collision on a play at first with 250-pound first baseman Jess Aguilar.

UP NEXT

Giants: LHP Ty Blach (4-2, 3.24 ERA) makes his first career start against the Brewers and ninth overall this season in place of injured Madison Bumgarner. Blach registered his first career complete-game shutout in his last start, a 10-0 win at Philadelphia.

Brewers: RHP Jimmy Nelson (3-3, 3.36) set a franchise record with double-digit strikeouts and no walks in each of his last two starts. Against the Giants, he is 1-2 with a 5.50 ERA in three career starts.