SAN FRANCISCO (AP) -- Eric Thames and Jesus Aguilar homered to help the Milwaukee Brewers avoid a sweep with a 5-3 victory over the San Francisco Giants on Sunday.
Christian Yelich had two doubles, extending his season-high hitting streak to 13 games. The reigning NL MVP is batting .472 (25 for 53) with five homers over that stretch.
Matt Albers (3-2) pitched the fifth for the win, allowing just one inherited baserunner to score after relieving Chase Anderson with the bases loaded and no outs. Anderson gave up three runs in four-plus innings.
Brandon Belt's sacrifice fly off Albers closed the Giants to within 5-3. Albers, Junior Guerra, Jeremy Jeffress and Josh Hader combined for five shutout innings of two-hit ball in relief for the Brewers. Hader pitched a perfect two final innings, striking out three to get his 17th save in 18 chances.
Thames' homer, his 10th of the season, off Giants starter Jeff Samardzija (3-6) in the fifth gave the Brewers a 4-2 lead. Samardzija gave up four runs on nine hits and two walks in five innings. The 34-year-old threw 114 pitches.
Aguilar hit a pinch-hit homer off Giants reliever Derek Holland leading off the sixth to make it 5-3.
The Brewers took an early lead on run scoring singles from Yasmani Grandal in the first inning and Ben Gamel in the second. The Giants tied it in the second, when Evan Longoria's leadoff triple started a two-run inning.
Yelich's double made it 3-2 in the fourth.
The Brewers had lost four of their previous five after winning straight.
The Giants had their season-high four-game winning streak snapped as they concluded their homestand at 5-3.
HOLE IN ONE
With two outs and Ben Gamel aboard in the top of the second, Yelich hit a drive to right that slipped through a small gap between the fencing doors in right field. The fluky play cost the Brewers a run with Gamel, who'd have easily scored if the ball remained in play, held at third on the ground rule double.
Brewers second baseman Mike Moustakas had one hit, extending his hitting streak to 10 games. ... Belt was 0 for 3, ending his18-game on-base streak.
GIANTS: LHP Will Smith got an off day after pitching in four games in five days. Smith worked a 28-pitch ninth for his 18th save on Saturday.
Brewers: RHP Jhoulys Chacin (3-7, 5.74 ERA) will come off the injured list (lower back strain) to start Monday's series opener in San Diego.
Giants: RHP Tyler Beede (0-2, 8.06) will make his first career start against the Dodgers in Monday's series opener.