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
On this date: Harper and Strickland square off in heated brawl
On May 29, 2017, Bryce Harper takes exception to getting hit by Giants pitcher Hunter Strickland, and Harper connects on a punch to the face of Strickland. Both players would be ejected.
What sweeping cuts mean for minor league baseball and its players
Hundreds of minor league ballplayers were released Thursday. Where does that leave them -- and the minors in general -- for 2020 and beyond?
Minor League Baseball cuts hundreds of players amid pandemic, sources say
With the minor league baseball season nearly certain to be canceled, hundreds of players were cut from their teams, with hundreds of more cuts expected, sources told ESPN.
Tommy's dream comes true as he gets to take infield practice with Cardinals
Cardinals fan Tommy Morrissey makes a great play at second base as he takes infield practice with the St. Louis Cardinals.
Texas to let fans attend pro sports events at 25% capacity
Texas Governor Greg Abbott has said the state will allow outdoor stadiums to host fans up to 25% of their normal capacity. Leagues will have to apply to state health officials to be allowed to have fans.
Jersey City brewery takes aim at Astros cheating scandal with 'Trash Can Banger' beer
Departed Soles, a brewery based in Jersey City, New Jersey, introduced a new beer called Trash Can Banger, featuring a can with the Astros' retro red-, orange- and yellow-striped colorway from the late '70s and early '80s.