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
Royals look for another solid effort vs. Orioles
The Kansas City Royals were able to put everything together in the first game of their three-game series against the host Baltimore Orioles on Monday night. Now, the Royals want to see if they can do it again when the two teams meet again Tuesday.
Strasburg faces Pirates, looking for career-high 16th win
Right-hander Stephen Strasburg has been a face of the Washington Nationals for most of this decade.
Diamondbacks score 3 in 8th to rally past Rockies, 5-3
Carson Kelly hit a tiebreaking solo homer in the eighth inning, part of a three-run rally that sent the Arizona Diamondbacks to a 5-3 victory over the Colorado Rockies on Monday night.
Angels back in Texas after Skaggs' death, Rangers rally, 8-7
The Los Angeles Angels returned to Texas for the first time since pitcher Tyler Skaggs was found dead in his hotel room before the start of a series at the Rangers last month, losing 8-7 in 11 innings after letting a six-run lead get away Monday night.
Cabrera, Gardenhire ejected during Tigers' loss to Astros
Miguel Cabrera gets ejected from the dugout for arguing balls and strikes. Ron Gardenhire comes out to argue and is tossed as well.
Abreu's 3-run homer helps White Sox beat Twins 6-4
Jose Abreu hit a towering three-run homer in Chicago's four-run second inning, helping Ivan Nova and the White Sox beat the Minnesota Twins 6-4 on Monday night.