SAN FRANCISCO — Matt Cain has lacked run support for so long now, over many years, he is hardly about to start pointing fingers at San Francisco's offensive production at this stage.

He pitched great again Tuesday night, with nothing to show for it but another loss to his name in the Giants' 3-1 defeat against the Milwaukee Brewers.

"It's tough when we're making some good pitches out there and we're going about it," Cain said. "We're not worried about the offensive guys, they're going to do their thing. We've just got to keep going out there and throwing the ball well."

Cain was handed his first loss since the All-Star break. The right-hander had been 2-0 with a 1.80 ERA in the second half, and certainly would have left with a win in this one if the Giants had made good on even one of their missed opportunities.

Brandon Crawford doubled to start the eighth but the Giants failed to bring him home for what would have been the tying run.

Manager Bruce Bochy is frustrated. They all are.

"We've been in position to win so many of these games. We've got to have somebody come through for us and that was missing again," Bochy said. "It's running rampant right now throughout the lineup. It's hit us as a club as a whole and it's been here for a while."

Carlos Gomez homered and Wily Peralta outdueled Cain to end a three-start winless stretch for the Brewers.

Gomez hit his 18th homer in the second as the Brewers jumped on Cain (7-7) early. Jonathan Lucroy added a ninth-inning sacrifice fly.

Peralta (8-11) struck out six of nine batters during an early sequence and finished with six Ks in 6 1-3 innings for his first career victory against the Giants.

"I needed an outing like that. I was struggling the last two," Peralta said. "I've been more comfortable because I've been working in the bullpen and I've been throwing (off-speed pitches) for a strike when I need to."

Cain allowed two runs and four hits in seven innings, struck out six and didn't walk a batter for the fifth time this year — but it wasn't enough with little help from a stagnant offense.

The struggling defending World Series champions are 2 for 22 (.090) with runners in scoring position in the first two games of the series. Pinch-hitter Joaquin Arias drove in a run on a groundout in the seventh as San Francisco avoided being shut out.

"It's hard to explain when you go through something like this," Bochy said. "Watching tonight, we had trouble catching up with the fastball. It's been a recent trend. The bats look a little slow."

Arias' fielding error in the ninth led to Milwaukee scoring an unearned run on Lucroy's sac fly. The Giants had gone four games without an error, but still have 80 for the second-most in the NL behind the Brewers.

In the fourth, Norichika Aoki doubled leading off the inning and advanced on Jean Segura's groundout. With Aoki well off third, catcher Buster Posey threw to try to get him.

But the throw sailed wildly into shallow left field past third baseman Pablo Sandoval, who wasn't close despite lunging to his left and Aoki scored.

Peralta had lost his previous two starts and was winless in three outings since back-to-back victories July 9 and 14. Peralta singled to start the sixth for his seventh career hit and sixth this year.

He received a no-decision in his only other matchup with San Francisco, a 10-8 Brewers win April 16 at Miller Park.

Jim Henderson pitched the ninth for his 16th save in 19 chances.

Posey, last season's NL MVP and batting champion, was hit by a pitch from Peralta above his left elbow with two out in the sixth, and Posey grimaced in pain as he slowly walked to first.

"It's frustrating. All of us take a lot of pride to be in those situations and come through," Posey said.

Bochy is considering trying Hunter Pence in the leadoff spot — perhaps now as soon as Wednesday night. While he had previously planned to rest Marco Scutaro in Thursday afternoon's finale, Scutaro will now get a break Wednesday after he went hitless in four at-bats Tuesday and is 0 for 9 overall in the leadoff spot the past two games.

"He needs a break," Bochy said.

Right-hander Marco Estrada returns to the mound for the Brewers on Wednesday night for his first start since June 3 after spending time on the disabled list with a left hamstring strain.

NOTES: Bochy said CF Angel Pagan is progressing well in Arizona from left hamstring surgery and could return to the Giants as soon as Sept. 1. ... San Francisco assistant GM Bobby Evans said the club is yet to sign LHP Ted Lilly to a minor league deal. He was designated for assignment July 25 by the Dodgers. "Upon reviewing Ted Lilly's medical history we're going to hold off on pursuing a minor league contract right now," Evans said. ... Giants LHP Barry Zito received the Lou Gehrig Memorial Award given annually by the Phi Delta Theta International fraternity to an MLB player. Zito started Strikeouts for Troops nine years ago to help returning veterans and their families with medical and other bills. "It's a huge honor," Zito said. "Lou Gehrig's name obviously is one that brings to mind a special feeling for most people."