Updated

PHOENIX (AP) Welington Castillo's three-run homer in the eighth inning rallied Arizona to a 6-5 victory over the San Francisco Giants on Saturday night, ending the Diamondbacks' six-game losing streak.

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.

Strickland (3-1) replaced Osich and gave up the game's biggest hit. Jake Barrett (1-0) earned his first major league win in relief and Brad Ziegler got his 17th save of the season.

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 Diamondbacks avoided their longest losing streak of the season.