SAN FRANCISCO -- Jim Henderson waited almost a month to prove he could be a multiple-inning closer.
He wasn't about to blow the opportunity Tuesday night, even with Pablo Sandoval standing between him and his goal.
Henderson retired Sandoval on a fly to left field to strand the potential tying run on third base in the eighth inning, then finished off the first four-out save of his career with a hitless ninth, allowing the Milwaukee Brewers to hold off the San Francisco Giants 3-1.
Wily Peralta carried a shutout into the seventh inning, and Carlos Gomez gave the Brewers a lead they never relinquished with a second-inning home run as Milwaukee made the most of just five hits to even the four-game series 1-1.
"We wanted to win the ballgame," Brewers manager Ron Roenicke said of calling upon his closer, Henderson, in the eighth inning. "Whatever we thought we had to do to win it."
Four of the Brewers' five hits came off hard-luck losing pitcher Matt Cain (7-7), who was outpitched by Peralta (8-11).
In winning for the first time since July 14, Peralta left with one out in the bottom of the seventh, up 2-0 but with runners on second and third. Right-hander Brandon Kintzler came on to get the final two outs of the inning, allowing the Giants' only run of the night on pinch hitter Joaquin Arias' grounder to second.
Peralta held the Giants to five hits and one run after he'd allowed 12 runs over 8 2/3 innings in his previous two starts. He walked two and struck out six.
"When you get a lead, you don't have to be so perfect," he said of his turnaround. "Sometimes you try to do too much. I was just trying to get guys out when you have two on the board."
The Giants also stranded the potential tying run on third base in the eighth. Brandon Crawford just missed an inning-opening home run, settling for a double high off the bricks in right field. Right-hander Rob Wooten replaced Kintzler at that point and retired the only two Giants he faced, including getting reigning National League Most Valuable Player Buster Posey on a grounder to third with one out and Crawford on third.
Roenicke then signaled for Henderson, who blew three saves when brought into games in the eighth inning in June. He hadn't gotten an opportunity to record a multiple-inning save since walking four in the eighth and suffering a loss against the Arizona Diamondbacks on July 11.
"The last time I tried to get more than three outs, all heck broke loose," said Henderson, who followed up the key out in the eighth by pitching a hitless ninth after the Brewers tacked on an insurance run in the top of the inning. He earned his 16th save.
"Sometimes you are going to have to record more than three outs," Henderson said. "That's been my goal. Ron hasn't let me do that ever since (the Arizona game)."
Milwaukee (48-65) won for the 40th consecutive time this season when leading after eight innings. Three Brewers relievers allowed just one hit over the final 2 2/3 innings.
"Fantastic," Henderson said of the relief work. "Tonight was a night when everybody picked everybody up."
The Giants' defense certainly didn't do the same for the team's pitchers. Milwaukee's last two runs were directly tied to San Francisco errors, even if only one of the two was considered unearned.
Cain allowed just four hits in seven innings, but three went for extra bases, including Gomez's solo shot to left field in the second. The right-hander gave up two runs, striking out six without walking a batter.
The Brewers' ninth-inning run was unearned after an error on second baseman Arias allowed Norichika Aoki to go from first to third with no outs. Aoki, who also scored Milwaukee's second run five innings earlier, raced home from third on Jonathan Lucroy's sacrifice fly to right field off the third Giants pitcher, Sandy Rosario.
Losing for the 11th time in their last 16 games, the Giants (50-62) out-hit the Brewers 6-5.
Gomez's home run was his 18th of the season and first since July 26. He had been hitless in his previous 18 at-bats.
The home run was the first allowed by Cain in his past eight starts. He began the season by giving up 16 homers in his first 14 starts.
Cain allowed only one other hit in the first five innings, but it also helped produce a run. Aoki doubled to lead off the fourth, and he scored to make it 2-0 one out later when Posey, the Giants' catcher, threw errantly while trying to pick him off third base.
"I tried to be a little bit too quick with it," Posey said of the called play. "That was the biggest issue."
The Giants went just 1-for-9 with runners in scoring position, Posey's late failure extended his slump in those situations to 1-for-11.
"It's frustrating," he said. "Our pitchers have been doing a really good job. All of us (hitters) take a lot of pride in being in that situation and coming through."
NOTES: Gomez's homer produced the 68th earned run of the season off Cain, who allowed only 68 earned runs all of last season. ... With Lucroy making just his second career start at first base, the Brewers used their 53rd different starting lineup in the past 65 games. ... Roenicke announced that the Brewers would activate RHP Marco Estrada from his injury rehab at Triple-A Nashville for a start Wednesday against Giants All-Star LHP Madison Bumgarner. ... Giants manager Bruce Bochy disclosed before the game the organization considered signing veteran LHP Ted Lilly to a minor league contract earlier in the day, but the 37-year-old couldn't pass his physical. ... Giants LHP Barry Zito was presented the Lou Gehrig Award by the Phi Delta Theta fraternity in a pregame, on-field ceremony. The honor is bestowed annually on the major league player who best exemplifies Gehrig's courage and unselfish character.