PHOENIX — The Arizona Diamondbacks finally got a shutdown performance from their bullpen, then benefited from a bases-loaded walk to end a long night and a four-game losing streak.

Welington Castillo drew a one-out walk to drive in Paul Goldschmidt with the winning run in the bottom of the 11th inning, sending the Diamondbacks to a 3-2 win over the Milwaukee Brewers on Friday night.

Goldschmidt led off the inning with a single off Blaine Boyer (1-2) and moved to second on Jake Lamb's single. One out later, David Peralta reached on an error to load the bases and Castillo walked on a 3-1 pitch from Boyer.

"It was a tough pitch. I am glad he didn't swing at it period because it might have been a double play ball," Diamondbacks manager Chip Hale said. "That was the zone all night. We saw that. That was at the bottom a little bit below the knees. He wasn't calling that. He (umpire Jeff Kellogg) was very consistent that way."

Boyer had some words for Kellogg as he headed into the dugout.

"I asked him how his family's doing, and he said they're doing good," Boyer joked. "That's what we do as pitchers, right? We think the umpires are wrong every time. I'm sure that call could have gone either way. It's 100 per cent on me. I didn't make my pitches when I needed to make them and that one hurts."

Reliever Adam Loewen (1-0) struck out two in a scoreless inning for his first win with the Diamondbacks. Loewen and five other relievers held the Brewers scoreless on two hits for five innings after three rocky outings from the bullpen in a series sweep by Washington.

"The bullpen, that was a big night for us," Hale said. Everybody looked good that came in did the job. The whole group. We have been tying to figure this thing out. To have some success is what you can build on."

Yasmany Tomas hit two solo home runs, going deep for the third straight game, for Arizona. He has a major league-leading six multi-home run games this season.

The Brewers failed to score in the top of the first despite a leadoff double by Jonathan Villar, who took third on an error by Tomas in left field. Villar was thrown out at home plate on a ground ball to shortstop, ramming into Arizona catcher Castillo on the tag.

Tomas' homer in the second put the Diamondbacks up 1-0.

"It is all about the way I am working. I am working really hard to make a good selection, on a good pitch," Tomas said through a translator.

Milwaukee tied it in the fourth on a two-out single by Orlando Arcia, his first major-league hit and RBI. Hernan Perez scored on the play.

Arcia was awarded third base when Diamondbacks second baseman Jean Segura, a former Brewer, threw the ball from Arcia's hit into the Milwaukee dugout before time had been called. Segura was charged with an error.

"He just threw the ball in right away. The play wasn't over yet," Brewers manager Craig Counsell said.

Tomas's 21st home run of the season cleared the right-field fence in the bottom of the fourth, giving Arizona a 2-1 lead. But the Brewers drew even on a long pinch-hit home run to lead off the seventh by Keon Broxton off Diamondbacks starter Braden Shipley.

Peralta took extra bases away from Arcia in the top of the ninth, reaching up to catch a fly ball near the fence. Kirk Niewenhuis dove to take a hit away from Castillo in the bottom of the ninth.

Chase Anderson allowed two runs and four hits in six innings against his former team, striking out five and walking two.

Shipley walked six in six-plus innings, allowing two runs and four hits.

TRAINER'S ROOM

Brewers: OF Domingo Santana has been on the 15-day disabled list since June 8 with right elbow soreness. ... INF Will Middlebrooks (lower right leg strain) is eligible to come of the 15-day DL on Aug. 9 and RHP Jacob Barnes (right elbow soreness) on Aug. 10.

Diamondbacks: RHP Zack Greinke is set to come off the disabled list in time to start next Tuesday in New York against the Mets. He's been out with a left oblique strain since late June. ... OF A.J. Pollock, who suffered a fractured right elbow just before the season started, was set to hit in a local minor-league game Friday night and could make his season debut before Sept. 1, Hale said. ... OF Socrates Brito was reinstated from the 15-day DL and optioned to Reno after the game.

UP NEXT

Brewers: RHP Matt Garza (2-4) will make his second start of the season against Arizona. He's 5-2 with a 2.88 career earned run average in nine appearances against the Diamondbacks.

Diamondbacks: Patrick Corbin (4-10) faces Milwaukee on Saturday. He's 2-2 with a 2.88 ERA in five career games against the Brewers.