PHOENIX -- Zack Greinke stymied Milwaukee's hitters most of the night, wriggling out of one jam while moving up baseball's all-time strikeouts list.
Once Arizona's ace left, the Brewers took advantage.
Mike Moustakas hit a three-run homer in the eighth inning and the Brewers scored six runs after Greinke left to beat the Diamondbacks 8-3 Saturday night.
"They got a good outing out from their starter, but we kept it close with some good pitching of our own," Brewers manager Craig Counsell said. "Then we had a good inning against a reliever having a good year."
Greinke allowed two runs and struck out nine in seven innings to move into 29th on baseball's all-time strikeouts list, leaving with a 3-2 lead.
He was replaced by Andrew Chafin (0-2), who allowed an infield single and a walk to set the table for Moustakas' 26th homer.
"It was right where I wanted it," Chafin said. "I wanted to go heater down and away and he just went with it. He beat me on a pitch."
The Brewers weren't done, either.
Milwaukee's bullpen made it possible.
Gio Gonzalez was solid in his return from the injured list before struggling in the fifth inning, but the Brewers' pen shut down the Diamondbacks.
Freddy Peralta struck out four in two innings and Adrian Houser (3-4) allowed a hit in 1 1/3 innings. Josh Hader struck out two after Ketel Marte hit a one-out triple off Houser in the eighth and Jeremy Jeffress worked around a walk in the ninth to close it out.
Arizona had one hit and two baserunners after Gonzalez left in the fifth.
"I can't say enough about the bullpen," Gonzalez said. "Those guys were lights out."
Eric Thames hit a solo homer for the Brewers, who have won four of five.
Greinke was good early against the Brewers before running into trouble in the fourth inning. Ryan Braun hit a run-scoring single and Milwaukee loaded the bases with one out after Thames was intentionally walked, but Greinke ended the threat with two strikeouts.
Greinke (2,548) passed No. 31 Tim Keefe (2,555) and No. 30 Jerry Koosman (2,556) on baseball's all-time strikeouts list. Greinke also had a run-scoring double.
"You feel like after seven innings Zack is throwing the ball extremely well, you are going to turn it over to your bullpen," Diamondbacks manager Torey Lovullo said. "You got the matchups you that you want. It is the beauty of this game. That is what makes this game so spectacular is that it was set up so perfectly for us and we just didn't execute."
Gonzalez had been out since May 29 with arm fatigue and the Brewers optioned right-hander Burch Smith to Triple-A San Antonio to make room for him on the roster.
The Diamondbacks wore Gonzalez out by the fifth inning.
Christian Walker hit a run-scoring single off the left-hander in the first inning and the Diamondbacks chased him with three straight doubles to open the fifth. Carson Kelly and Greinke put Arizona up 3-1 with their run-scoring doubles.
In the bottom of the fourth inning, two women were escorted away by security after climbing onto Milwaukee's dugout and unfurling a banner. The two women held each end of the banner and fans began throwing debris at them before security arrived to take them off the dugout.
In the top of the eighth inning, a fan jumped over the left field wall as Thames popped out and was quickly tackled by security. The man struggled against several officers and twice dropped to the ground. He was led away after one officer pulled off his pants and shoes.
Diamondbacks: RHP Matt Andriese (left foot contusion) was placed on the 10-day injured list after taking a liner off the foot against the Brewers on Friday night. Arizona recalled RHP Stefan Crichton from Triple-A Reno to take his roster spot. ... OF David Peralta took batting practice and ran the bases before the game in his return from an inflamed right shoulder. He could go on a rehab assignment soon.
Brewers: RHP Brandon Woodruff has four straight quality starts heading into Sunday's series finale. The first-time NL All-Star allowed a run on five hits in 6 2/3 innings against Atlanta on Tuesday.
Diamondbacks: LHP Alex Young has made a strong case to remain in the rotation, going 3-0 with a 0.96 ERA in four starts to open his rookie season.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Rockies to retire Larry Walker's jersey on April 19
The Rockies will retire Larry Walker's No. 33 jersey on April 19, joining Todd Helton (17) as the only players to be so honored by the team.
Jack McDowell says Tony La Russa had sign-stealing system with White Sox in '80s
Former White Sox pitcher Jack McDowell, who never played for Tony La Russa, said a camera-aided sign-stealing system was set up by the Hall of Fame manager prior to his being fired, and that was used after McDowell made his debut in 1987.
Onley: Mets, Red Sox, Astros will have no problem replacing managers
Buster Onley breaks down the potential managerial candidates for the Mets, Red Sox and Astros after the sign-stealing scandal fallout.
Stephen A.: MLB should take away Astros' World Series trophy
Stephen A. Smith emphatically calls for the MLB to confiscate the Astros' World Series trophy and take the players' championship rings for their sign-stealing scandal.
Source: MLB ineligible list ends at death for banned players
Major League Baseball has no hold on banned players after they die, a source told ESPN, which could be significant when it comes to Hall of Fame consideration for "Shoeless" Joe Jackson and others who were banned for life and have since died.
How the internet helped crack the Astros' sign-stealing case
From video breakdowns to screengrabs to players weighing in, social media shaped MLB's first uniquely 21st century scandal.