SAN FRANCISCO (AP) Wily Peralta hoped his strong rehab starts would carry right over into his big league return, and he delivered quite a performance in his first outing in more than two months. He only had to guard against his Adrenalin being too high.

Peralta returned from the disabled list and shut down one of baseball's hottest teams, pitching the Milwaukee Brewers past the San Francisco Giants 5-2 on Tuesday night to snap the team's three-game losing streak.

Peralta (2-5) retired the initial six batters on the way to his first win since May 6, outpitching Matt Cain (2-2) as the Brewers also ended a seven-game skid to San Francisco - matching the longest in the series.

More from FoxSports

''I was commanding pretty good, my fastball was down and my sinker was working and I could get a bunch of ground balls when I needed to,'' Peralta said. ''When I'm commanding my pitches, I know I'm going to have a great game. It doesn't matter what team it is.''

Milwaukee got plenty of contributions from throughout the order on a night slugger Ryan Braun missed his second straight game because of back spasms that came on during pregame warmups Monday and forced a late lineup scratch.

Carlos Gomez hit an RBI double a day after being ejected and Adam Lind singled in a run and hit a sacrifice fly after missing two games with a tight back as Milwaukee ended the Giants' seven-game home winning streak and six straight overall. Jonathan Lucroy hit a sacrifice fly, while leadoff hitter Gerardo Parra tripled, doubled, singled and scored three runs. He has a 12-game hitting streak, longest by a Brewers player this year.

Peralta allowed both runs and five hits in six-plus innings, struck out three and walked two in his first start since May 22 after being sidelined with a strained left oblique. Francisco Rodriguez finished for his 23rd save in Milwaukee's first win in the last six meetings at AT&T Park.

''He was excellent,'' manager Craig Counsell said. ''There was certainly no rust the way he pitched. He was really in control of his effort all night. His sinker was really good because of that. That's the really good Wily Peralta.''

Cain, too, has had a slow start to the season after missing the first three months of the year with a strained flexor tendon in his pitching arm.

He gave up four runs and eight hits in six innings making his fifth start. He dropped to 0-3 over his last four home starts against Milwaukee but hadn't faced the Brewers at AT&T Park since 2013.

The defending World Series champion Giants, 9-2 since the All-Star break, lost for only the second time in 14 games with a chance to go a season-best 12 games over .500.

With the first-place Dodgers losing at home to Oakland, the Giants missed a chance to take the NL West lead for the first time since May 29 and instead remained a half-game back.

''It doesn't matter where you're at right now, to be honest,'' manager Bruce Bochy said. ''It's a little early to be doing that. It's all about going out there, playing well and winning ballgames. It's pretty simple at this stage. There's a lot of baseball left.''

TRAINER'S ROOM

Brewers: Counsell expects Braun's back issue to be ''short term.'' ''Just day to day with it, really just trying to get it better,'' Counsell said. ''He's had similar stuff to this in the past.'' ... Milwaukee optioned RHP David Goforth to Triple-A Colorado Springs to clear roster room for Peralta's return.

Giants: 2B Joe Panik will likely get another day off Wednesday because of back stiffness. ... Closer Santiago Casilla said he had a tight area on the right side of his neck before the All-Star break perhaps caused by sleeping on it wrong, but he is feeling great again. He made his career-high 26th save Sunday before getting a break Monday. ... Bochy expects to give Buster Posey a break from catching for Wednesday afternoon's series finale.

UP NEXT

Brewers: RHP Mike Fiers (5-8) faces the Giants for a second time this season looking to beat them for the first time in his career after an 0-2 record over three games and two starts. He lost 3-1 on May 27 at Miller Park.

Giants: RHP Jake Peavy (2-4) makes his seventh start of the year after missing all of May and June with a strained lower back. He is 4-4 with a 2.44 ERA in 12 career starts against the Brewers.