SAN FRANCISCO (AP) -- Unable to produce a clutch hit, the San Francisco Giants still found a way to win.
Brayan Villarreal walked Marco Scutaro with the bases loaded and two outs in the bottom of the ninth, handing the Giants a 3-2 victory over the Boston Red Sox on Tuesday night.
The Giants squandered numerous opportunities early in the game, going 0 for 10 with runners in scoring position, but they tied it in the eighth inning on a sacrifice fly in foul territory and used two walks and a hit batsman to win it.
''We have been on the other end of these games,'' manager Bruce Bochy said. ''You take it any way you can get it. This was a good one.''
Roger Kieschnick started the winning rally with a one-out single against Franklin Morales (2-1) for his third hit of the game. The Giants loaded the bases with two outs when Morales walked Andres Torres and hit pinch-hitter Hector Sanchez on the left wrist.
''We started out the inning in pretty good shape and then seemingly in a matter of about seven or eight pitches it looked like Franklin lost the strike zone a little bit and leaves us in a tough spot with two outs,'' Red Sox manager John Farrell said.
With Brandon Workman having pitched the past two days, Farrell gave Villarreal his first appearance with the Red Sox. Villarreal was acquired in a deal last month from Detroit and called up from Triple-A Pawtucket on Monday.
He made a poor first impression, throwing four straight balls to Scutaro. Giants hitting coach Hensley Meulens told Scutaro that Villarreal had control problems before the at-bat and that proved true. Villarreal has walked nine of 29 batters he has faced this season, including two with the bases loaded.
''When he told me that, I wanted to make sure I looked for my pitch and not be too aggressive,'' Scutaro said.
He did just that, giving the defending World Series champion Giants a rare reason to celebrate.
''It's nice to win one like this because we have been on the other side of them,'' said starter Ryan Vogelsong, who allowed two runs in seven innings. ''When you play a tough game like that and things aren't going your way ... it's good to come out on the winning end of it.''
The Red Sox couldn't hold a 2-0 lead and lost for the fifth time in seven games to fall percentage points behind Tampa Bay for the lead in the AL East.
Sergio Romo (4-6) pitched a perfect ninth for the win.
After twice failing to get a runner in from third with no outs, the Giants finally delivered in the eighth inning to tie the game.
Scutaro reached on a one-out single and went to third on Brandon Belt's single against Junichi Tazawa. Buster Posey then hit a high fly down the right-field line that Shane Victorino caught in foul territory. Scutaro scored easily on the sacrifice fly but Tazawa escaped without any further damage to keep the score tied at 2.
''No second-guessing guys. I let that ball fall and he hits a three-run homer then what are you guys going to say?'' Victorino said. ''When I was on the move over there I told myself catch the ball and try and get in the best position I could to make the throw.''
Victorino helped give Boston the lead when he hit a rare right-handed homer off a righty pitcher. The switch-hitting Victorino is unable to bat left-handed because of an injured left leg. But that did not bother him when he led off the third inning with a drive to left that made it 2-0.
It was just the second time Victorino had hit a right-handed homer against a righty in his career, also doing it against knuckleballer R.A. Dickey on Sept. 24, 2010, according to STATS LLC.
It looked as if that 2-0 lead would stand up when Jake Peavy escaped jams in the fourth and fifth innings. Belt, who had three hits, was stranded after a leadoff triple in the fourth when Posey grounded out and Peavy struck out Hunter Pence and Brandon Crawford.
The Giants scored their first run of the series when Kieschnick led off the fifth with a single and scored on Joaquin Arias' triple. But San Francisco couldn't get the equalizer when Vogelsong, Gregor Blanco and Scutaro followed with groundouts.
NOTES: SS Xander Bogaerts (20 years, 323 days) became the youngest position player to appear in a game for Boston since Dwight Evans (20, 318) in 1972. He went 0 for 3 and stranded five runners. ... San Francisco 3B Pablo Sandoval was scratched because of a sore back. ... Boston RHP Clay Buchholz (neck and shoulder) threw 46 pitches in a simulated game and is set to make a rehab start Sunday. Farrell said he would like Buchholz to get three rehab starts but he might only get two depending on the minor league schedule. ... LHP Barry Zito (4-8) makes his first start of the month for the Giants in the series finale Wednesday after Chad Gaudin was placed on the DL. Felix Doubront (8-6) goes for Boston.