MILWAUKEE -- Jimmy Nelson didn't have his best stuff Wednesday night, but it was still enough for the Milwaukee Brewers.
Nelson (4-3) held the Giants to three runs on seven hits and a walk with six strikeouts over six innings.
"He kind of had to battle through it," Brewers manager Craig Counsell said. "It's tough to be as sharp as he was his last outing (eight shutout innings against Clayton Kershaw and the Los Angeles Dodgers), but he battled through it. He just competed really well and got through it."
Villar also came up big on defense, making a sliding grab to rob Buster Posey of a hit in the fifth inning, then turning a crucial double play that got Nelson out of a jam in the sixth.
"Villar made some big plays," said Nelson, 3-1 with a 2.81 ERA over his past seven starts. "Offensively, we did what we always do. Those guys did a good job of picking me up."
Ty Blach (4-3) went six innings for the Giants, allowing five runs on nine hits. He didn't walk a batter for the third time in his past four starts, and he struck out three.
"I thought he had good stuff," Bochy said. "He had a few more balls up than normal for him. But overall, I know the numbers didn't look great."
Santana's first-inning home run gave Nelson a 1-0 lead.
Nelson blanked the Giants through his first two innings, extending his scoreless innings streak to 13, but ran into trouble in the third when Eduardo Nunez singled and scored on a Brandon Belt double to tie the game.
Buster Posey sent Nelson's next offering to straightaway center for his eighth homer of the season, putting the Giants up 3-1.
"It was just bad pitch selection on my part," Nelson said. "I threw him a first-pitch slider after I threw him one in his first at-bat."
Milwaukee got the runs back in the fourth. Jesus Aguilar led off with a single and took second on an error by left fielder Orlando Calixte. Travis Shaw drove in Aguilar with a single. After Hernan Perez reached on a double, Manny Pina knocked in Shaw with a sacrifice fly to right, making it 3-3.
Santana singled with two outs in the fifth and scored when Aguilar doubled down the right-field line, putting Milwaukee ahead.
"After the first time through (the lineup), we saw that (Blach) was throwing a lot of off-speed and a lot of changeups," said Aguilar, who went 2-for-4. "We were just trying to make adjustments to go up the middle and the other way."
Orlando Arcia made it a 5-3 game when his double drove home Pina in the sixth, and Villar led off the seventh with his homer to put the Brewers up by three.
"We kept the pressure up every single inning and just kept adding on," Counsell said.
Milwaukee's bullpen had struggled for much of the last week but came up big Wednesday. Jared Hughes and Jacob Barnes kept San Francisco off the board in the seventh and eighth innings, respectively, and Corey Knebel struck out two in the ninth inning to earn his seventh save.
"It was still a tight game, and those guys got some big outs," Counsell said. "Jacob had to go through the middle of their lineup. It was solid work."
NOTES: The Brewers placed RHP Matt Garza on the 10-day disabled list due to a chest contusion and reinstated 3B Travis Shaw from the paternity list. ... Milwaukee will bring RHP Paolo Espino back from Triple-A Colorado Springs on Thursday to start in place of Garza. Espino made his major league debut May 19 at Wrigley Field, holding the Cubs to three earned over four innings. ... OF Domingo Santana hit a solo home run in the first inning, giving Milwaukee 56 first-inning runs in 60 games this season. ... RHP Sam Dyson is expected to join the Giants on Friday when they return to San Francisco to start an interleague series with the Minnesota Twins. He was acquired Tuesday from Texas along with cash considerations in exchange for a player to be named. ... The Giants are 11-23 on the road this season. ... Brewers starting pitchers are 7-1 with a 1.46 ERA over the past 13 games.