PHOENIX -- Tim Locastro has been hit by pitches 12 times in 102 plate appearances this season. Avoiding it with the bases loaded on Sunday still worked in his favor.
Locastro's single in the 10th inning gave the Arizona Diamondbacks a 3-2 win over the San Francisco Giants, a line drive to left field that scored Nick Ahmed and helped the Diamondbacks end a season-long six-game losing streak.
The first pitch of Locastro's at-bat in the 10th against Giants reliever Mark Melancon almost hit him. Locastro turned out of the way.
"We would have won either way but I wanted to get a hit there," Locastro said. "I wasn't exactly trying to get away but it happened to miss me."
Melancon (3-2) uncorked a wild pitch to put runners at second and third with one out, and Carson Kelly was intentionally walked to bring up Locastro.
"Actually with that pitch not hitting me, I sort of knew his approach was to come in a little bit," Locastro said, "so I was looking in there and I was able to fight it over the third baseman's head and drop it in for a single."
Matt Andriese (4-4) pitched a scoreless top of the 10th to earn the win. He was the last of four relievers that held the Giants hitless for four innings.
"I have come in here for five straight days talking about losing a baseball game, and that's hard," Diamondbacks manager Torey Lovullo said afterward. "It's hard for me. It's hard for the team. It's hard for everybody, but we've got to find a way to keep grinding to have these (winning) moments happen."
Christian Walker had three hits for Arizona, extending his hitting streak to a career high eight games.
Kevin Pillar homered for the Giants, his 10th of the season, but San Francisco was held to four hits for the game.
"We just couldn't get anything going with the bats," Giants manager Bruce Bochy said. "They got the big hit, we didn't. That's the difference in the game."
Locastro rolled a single into shallow right field, the Diamondbacks' first hit of the game, driving in Caleb Joseph with two outs in the third inning. The Giants tied the score at 1 on Stephen Vogt's ground out to score Evan Longoria from third base in the top of the fourth.
Arizona went back in front 2-1 with Walker's RBI single in the fourth, the result of a nine-pitch at-bat that drove in Adam Jones, who'd reached on a wild pitch third strike.
Pillar led off the seventh inning with a solo shot to left field, which spelled the end of Diamondbacks starter Merrill Kelly's day. Kelly went six innings and allowed two runs on four hits, striking out nine.
The Diamondbacks opened their half of the seventh with back-to-back hits off Giants starter Shaun Anderson to put runners on second and third, and the Giants turned to Reyes Moronta in relief. Moronta worked out of the jam without allowing a hit.
Anderson allowed two runs on five hits in six innings.
"I just stayed with the same game plan. I attacked them early and got some quick outs," Anderson said. "Our bullpen has been absolutely dominant all year. I don't think they get enough credit for what they do."
The Diamondbacks were primed to take the lead in the seventh with Ahmed up to bat and runners in scoring position with no outs. Moronta threw a pitch to the backstop, but the carom arrived cleanly to catcher Vogt's glove, and Vogt had plenty of time to tag out Eduardo Escobar trying to score from third base.
The Diamondbacks failed to score in the inning.
Giants: Vogt took a foul ball of his right knee in the bottom of the fifth inning and was limping badly for a few moments immediately afterward, but remained in the game. After the game his knee was heavily wrapped. "I'm sure he's going to be sore tomorrow," Bochy said of Vogt.
Diamondbacks: 2B-OF Ketel Marte was held out of the lineup for a second straight day due to a minor groin injury from Friday's game.
Diamondbacks: RHP Zack Greinke (8-3, 2.91) is tabbed for the opener of a three-game series against the Los Angeles Dodgers starting Monday. He could face the Dodgers' Clayton Kershaw, a former teammate and fellow Cy Young Award winner, for the second time in his career.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Kay back in Yanks' broadcast booth after surgery
Veteran play-by-play announcer Michael Kay, who had surgery to remove a nodule from his vocal cord in early July, is returning to the Yankees' broadcast booth Saturday.
Yanks' Boone: Worth exploring MLB 'mercy rule'
Yankees manager Aaron Boone wouldn't mind seeing the MLB consider a "mercy rule," saying it would be nice to end a game that had gotten out of hand early rather than go through the motions of completing nine innings.
Dodgers to try top prospect May as reliever
The Los Angeles Dodgers will try Dustin May, their top pitching prospect, as a reliever this weekend as they look to determine if he'll have a place on their postseason roster.
McCann, White Sox hope to slam Angels again
James McCann wasn't a feared offensive threat before joining the Chicago White Sox in the offseason.
Giants' Webb set for major league debut vs. D-backs
A pair of call-ups from Triple-A will try to cool off homer-happy lineups when the Arizona Diamondbacks and San Francisco Giants continue their four-game series Saturday night in Phoenix.
Twins' Berrios aims to seal series win at Texas
All-Star right-hander Jose Berrios gets the start on Saturday night as the Minnesota Twins try to clinch a series victory over the Texas Rangers in Arlington, Texas.