PHOENIX -- The San Francisco Giants have 41 wins this season when leading after seven innings. They were in position for No. 42, and their 52nd victory of 2016, until Welington Castillo spoiled it.
Castillo's three-run homer in the eighth inning rallied Arizona to a 6-5 victory over the Giants, ending the Diamondbacks' six-game losing streak and sending NL West-leading San Francisco to its first defeat in six games at Chase Field this season.
Castillo ripped reliever Hunter Strickland's 2-1 pitch into the stands in left field with one out. The Giants led 5-3 going into the inning, but starter Jeff Samardzija and reliever Josh Osich each put runners on base.
"I tried to throw a two-seamer, left it over the plate and it didn't move," Strickland said. "I would say he got the best of it. I was trying to throw it in. I was trying to get a ground ball."
"That is one we let get away," Giants manager Bruce Bochy said. "Just bad location there. We just couldn't tack on. Their pen did a pretty good job on us."
The Giants haven't let many get away. They'd lost only four previous games when holding a lead entering the eighth inning.
Brandon Crawford and Mac Williamson hit back-to-back home runs to give the Giants a 5-1 lead in the fourth. Williamson's blast flew well over the 413-feet sign in left-center field and off the bottom left corner of the Chase Field video board.
The Giants scored their first three runs in the second inning. Buster Posey walked, took third on a single and scored on a fielder's choice when Diamondbacks shortstop Jean Segura threw wide to home plate for an error after fielding Williamson's grounder.
Recent callup Ruben Tejada's first hit and RBI as a Giant came one out later, on a single to drive in Crawford. Then Samardzija grounded to Segura, who bobbled the ball and could only get one out to allow Williamson to score.
Patrick Corbin doubled and scored in the fourth thanks to teammate Michael Bourn's hustle. Bourn beat out what looked to be an inning-ending double-play grounder at first base, allowing Corbin to score from third.
Castillo and Chris Herrmann doubled in runs in the fifth - Herrmann's drive close to being a home run to right-center field - to cut the Giants' lead to two.
Samardzija allowed four runs on eight hits in 7 1/3 innings. He struck out five without a walk.
Giants: OF Denard Span got another day off due to neck stiffness but could be back by Sunday. ... OF Hunter Pence(hamstring strain) took on-field batting practice Saturday. He's been on the 15-day disabled list for a month. .. Starting pitcher Matt Cain was scheduled to throw 45 pitches in a minor league game Saturday as he returns from a hamstring strain. ... 2B Joe Panik (concussion) is still resting and is eligible to return Tuesday.
Diamondbacks: Manager Chip Hale said ace Zack Greinke felt better during Friday's game, and the team has yet to decide whether to place Greinke on the disabled list with a left oblique injury. Greinke was expected to undergo a scan Saturday to determine if he has a strain. Greinke could pitch as soon as next weekend if all is well and can still be named an NL All-Star, but may not pitch in San Diego. ... OF David Peralta and OF-IF Chris Owings, both on the 15-day disabled list, are moving closer to being able to play in games. They could be back in action after the All-Star break, Hale said. OF Socrates Brito (fractured toe) is also close to returning from the DL.
Giants: Sunday's scheduled starter is Albert Suarez (3-1, 3.83 ERA), who is in the rotation in place of Cain. "He's done such a great job in whatever role we've put him in," Bochy said.
Diamondbacks: Sunday starter Robbie Ray (4-7, 4.69 ERA) is 1-0 with a 1.64 ERA in two starts against the Giants in his career. He is averaging 10.42 strikeouts per nine innings pitched, which is in the top 10 in the NL.