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
Fantasy baseball: Harper, Machado among overrated hitters
For as good as players like Bryce Harper and Manny Machado are, they haven't been matching the fantasy baseball hype. Here's a look at hitters not living up to their ADP.
Verlander, Astros historic favorites against Tigers
The Astros are listed as -500 favorites over the Tigers at Caesars Palace and as high as -550 at other sportsbooks, making them the heaviest favorite in a game in at least the past 15 seasons.
'You're the guy with the ball to the crotch': The inside story behind the funniest baseball card ever made
Thirty years ago, Keith Comstock turned a routine minor league baseball card shoot into an unforgettable baseball-to-the-groin image. This is how the legendary card came to be, in the former pitcher's own words.
His bat handle says what?! 10 of the most hilarious and unforgettable baseball cards
The infamous Billy Ripken error. A very serious cellphone call. A giant sombrero ... and more. We put together a 10-pack of cards sure to make you smile.
Is 2019 the greatest season ever for players making their MLB debuts?
Guerrero Jr., Tatis, Alonso, Alvarez, Bichette and many more. We compare the players who played their first games in 2019 to the top rookie crops from other years in MLB history.
Oakland's Fiers puts hot streak on line vs. Yanks
Right-hander Mike Fiers will attempt to extend his streak of unbeaten starts to 19 and the host Oakland Athletics will go for a second consecutive win over the New York Yankees when the clubs continue their three-game series Wednesday night.