PHOENIX -- Didi Gregorius might have to have his family visit from Curacao more often.
"I see this every day," said Gregorius, who was playing in front of his parents and his brother. "We never back down. We fight hard. We never give up."
Miguel Montero and Jason Kubel also homered and Eric Chavez drew a bases-loaded walk to drive in the go-ahead run for the Diamondbacks, who have won three straight overall and all six meetings against Milwaukee this season.
"All in all, the guys were resilient and got the job done," said Diamondbacks manager Kirk Gibson, whose club maintained its 2 game lead over the Los Angeles Dodgers in the NL West.
Will Harris (2-0) threw a perfect seventh inning in relief of Randall Delgado for the win. Brad Ziegler pitched the ninth for his third save overall and second in three nights.
Arizona has come from behind in 27 of its 50 wins.
"When you get down towards the end, the games get a little tighter and there is more pressure and every pitch counts," Chavez said. "We put together good at-bats and the bullpen was able to shut the door. It's building confidence toward the end of the year."
Brewers starter Kyle Lohse (5-7) allowed only five base runners in 6 1-3 innings, but all five scored.
With Milwaukee leading 4-2 in the bottom of the seventh, Lohse retired Paul Goldschmidt before allowing Kubel's home run. Cody Ross singled and Montero walked, ending Lohse's night.
John Axford relieved but didn't record an out.
The right-hander walked Martin Prado on four pitches to load the bases, gave up a game-tying single to Gregorius and issued a bases-loaded walk to pinch hitter Chavez, scoring Montero to give Arizona its first lead at 5-4.
"Warming up I felt good," Axford said. "In the pen, things were good. But the first two sliders I threw, I tried to do too much and it threw me maybe a little bit. I was just trying to throw a great slider, maybe pulled myself off and threw off my mechanics."
Lohse allowed four hits, walked one and struck out five and Jonathan Lucroy hit his 13th home run for the Brewers, who have lost four in a row.
"We're outhitting these guys and we're getting beat by them," Brewers manager Ron Roenicke said. "That's tough. They're hitting the home runs. When they get a mistake, they're just not getting a base hit they're hitting a home run."
Lohse gave the Brewers a 1-0 lead in the second when he drove in Logan Schafer from second on a single up the middle.
Montero tied the game at 1-1 in the bottom of the fifth on the Diamondbacks' first hit.
But in the sixth, Jean Segura singled and Lucroy followed with his second home run in three games to put the Brewers ahead 3-1. Carlos Gomez walked and later scored on a two-out passed ball to make it 4-1.
Gregorius homered with one out in the sixth to pull Arizona within 4-2.
"I had good stuff going, but the mistakes I made they put it of the park. After that I lost a little control," Lohse said. "You make mistakes and you pay for it."
Delgado allowed four runs -- three earned -- and eight hits and a walk and struck out five.
The Diamondbacks have 50 wins before the All-Star break for the fifth time in club history but the first time since 2003.. Lohse has allowed 19 home runs in 115 1-3 innings, tying Washington's Dan Haren for the most allowed by an NL pitcher this season. ... Brewers left fielder Ryan Braun missed his third straight game on bereavement leave. Braun played Tuesday after missing 26 games with an inflamed nerve in his right hand then sat out Wednesday's game with a sore right thumb before leaving the team to deal with a family medical issue. Players on the bereavement list must miss at least three games but no more than seven. ... The Diamondbacks have at least one extra-base hit in an MLB-best 78 straight games. ... Diamondbacks RHP Ian Kennedy (3-5), 0-2 with a 6.48 ERA in his past six starts, will take on RHP Wily Peralta (6-9) in the teams' last game before the All-Star Break.