SAN FRANCISCO -- The Arizona Diamondbacks took out a week of frustrations on San Francisco's pitching staff.

Ildemaro Vargas had five hits and a home run, Adam Jones added four hits and a homer, and the Diamondbacks broke out of a slump in a big way, beating the Giants 18-2 on Friday night in the highest-scoring game in 20 seasons at San Francisco's waterfront ballpark.

"We needed it," said bench coach Jerry Narron, who filled in for manager Torey Lovullo. "Everybody knew we were going to break out at some point and someone would pay for it. Tonight was the night. Hopefully everybody can relax a little bit and swing the bat more aggressively."

Arizona had been held to 12 runs during a five-game losing streak before unleashing its bats on Drew Pomeranz (1-5) and an overmatched Giants bullpen.

Robbie Ray (4-1) was the beneficiary of the big offensive night, giving up two runs in 5 1/3 innings to win his fourth straight decision. Ray even got into the act on the offensive side with a two-run single in the third inning for his first hit of the year. He retired 13 in a row at one point with eight strikeouts in that span.

"That was me at my best today," Ray said.

Ray had plenty of help. Vargas homered in the first inning, and the Diamondbacks turned it into a laugher against reliever Nick Vincent with three-run homers by Jones in the fifth and Eduardo Escobar in the sixth inning.

Ketel Marte added a three-run homer off Derek Holland in the seventh, prompting cheers of "Let Pablo Pitch!" from the few fans remaining who were hoping that Giants infielder Pablo Sandoval could get his second appearance on the mound this season. But manager Bruce Bochy didn't oblige because he plans to start Sandoval at third base Saturday and didn't want him to have a sore arm.

Every member of the Diamondbacks' starting lineup either scored or drove in a run in Arizona's highest-scoring game of the season following a team meeting in San Diego after the latest loss Wednesday and a day off.

"It grinds on you," catcher Carson Kelly said. "When that happens, you want to be the guy to do too much. We just said, 'You know what, let's slow things down. We know we're a good team. Let's pick each other up.'"

Tyler Austin hit a two-run homer in the first inning for San Francisco, his third straight game with a home run. The Giants managed nothing else against Ray and fell to 1-4 on the homestand.

"Occasionally, you're going to have a game like this," Bochy said. "Trust me, they're not fun, especially at home. Started out rough, gradually got worse."

Zack Godley pitched three innings for his second save.

Pomeranz had another rough outing against an NL West opponent, giving up the solo homer to Vargas in the first, RBI singles to Marte and Vargas in the second, and then the two-run single to Ray in the third that ended his night. Pomeranz gave up five runs and eight hits in 2 2/3 innings, falling to 4-18 with a 5.34 ERA in his career against NL West teams.

TRAINER'S ROOM

Diamondbacks: LF David Peralta was put on the injured list because of an injured right shoulder. 1B Kevin Cron and OF Tim Locastro were called up from Triple-A Reno. Arizona had an open spot on the 25-man roster after sending pitcher Jimmie Sherfy to the minors.

Giants: SS Brandon Crawford missed his second straight game because of pink eye. ... C Buster Posey was held out of the lineup a day after catching 13 innings.

BALL MAGNET

Locastro was hit by pitches three times in the game. Pomeranz hit him in the third inning, Vincent in the sixth and Holland in the seventh. Locastro has been hit seven times this season in only 29 plate appearances.

FILLING IN

Lovullo missed the game to attend the high school graduation of his youngest son, Connor. Narron filled in as manager, and Luis Urueta took over as bench coach. Lovullo is expected back Saturday.

UP NEXT

The Diamondbacks will call up RHP Taylor Clarke (0-1) from Reno to start Saturday's game against Andrew Suarez (0-1). Arizona will need to make a roster move before the game to make room for Clarke.