"I thought Yo was spectacular," Brewers manager Ken Macha said. "[He had an] excellent fastball and a hard breaking ball. The priorities were throwing high fastballs by some guys and getting some guys to chase his breaking ball in the dirt. That's a pretty good combination."
Gallardo gave up a home run to Pablo Sandoval with two out in the first inning, but allowed just three more hits from there. He finished with four hits allowed, striking out nine, to improve to 8-4 on the year.
Friday's outing was Gallardo's ninth quality start of the season and the 10th time the Brewers won in Gallardo's 15 starts. The 23-year-old right-hander has struggled all season with walks -- putting six men on base against Cleveland on June 16 and four others in each of his previous two starts -- but issued three walks in his last outing against Detroit.
Gallardo continued to show that improved command from Sunday's hard-luck outing against Detroit, walking just three batters Friday, two of which came in the eighth inning with his pitch count rising.
"I think the most important thing was I was able to place my fastball wherever I wanted and just get it down and away [and] fastballs in," said Gallardo, who came out in the eighth inning after throwing 118 pitches. "It just opened my curveball up."
On a night when Gallardo made just one mistake -- the high changeup to Sandoval in the first inning -- the Brewers' offense gave him plenty of breathing room.
The Brewers quickly got over the early deficit, putting up two runs in the bottom of the inning off Cain.
Craig Counsell led off the inning with a triple, and Ryan Braun and Casey McGehee followed with a pair of RBI doubles to put Milwaukee up, 2-1.
J.J. Hardy hit a solo home run to center field in the third inning -- the 500th hit of his career -- and also picked up an RBI single in the Brewers' two-run fifth inning.
Hardy, who moved up to the second spot in the lineup after spending the past 10 games in the bottom third of the order, entered the game with a .215 batting average and just three hits on the homestand. Prior to the game, Macha said it seemed like all balls Hardy hit hard were caught, while the softer hits fell in play.
Hardy agreed with that assessment and said in his current rough stretch he wasn't sure about either of his two hits when the ball came off the bat.
"You just have that feeling that you're not going to have many hits, so when I hit that [home run] I thought [Giants center fielder Aaron Rowand] was going to go back there and make a catch or something," Hardy said. "When it went out, it was a good feeling."
The Brewers handed Cain (9-2) just his second loss of the year, scoring five runs on six hits in seven innings off the young right-hander. Cain finished with nine strikeouts, walking four, as his career-high seven-game winning streak was snapped.
The series-opening win against Cain and the Giants was big for the Brewers, who have two more games against the Majors' top pitching staff. Barry Zito takes the hill for the Giants on Saturday, and while Sunday's starter is still listed as "TBA," there is a chance the Brewers could face 2008 NL Cy Young Award winner Tim Lincecum.
Add in the rest of their opponents before the All-Star break and Macha said the Brewers' schedule ranks an eight on a toughness scale of 1-to-10.
"We've got a very difficult stretch here and I think we just have to look at each game by itself. Zito's pitched well as of late, so we've got our work cut out for tomorrow," Macha said. "But it's nice after having what I would term a 'disappointing' series against Minnesota, it's nice to start this series off with a win."