MILWAUKEE -- Stephen Drew has had some luck in the past against Trevor Hoffman. He did one more time.
"You can't do too much because that changeup is good," Drew said of Hoffman's signature pitch. "That's why he's got 597 saves. He knows what he's doing."
Hoffman (2-5), who earned his first save in three months on Saturday night, came on to pitch the 10th after the Diamondbacks tied it at 4 in ninth.
Kelly Johnson doubled to left with one out. With two outs, Miguel Montero was walked intentionally to face Mark Reynolds who walked on a 3-2 pitch to load the bases. Drew slapped a 2-2 pitch up the middle for two runs. Church, hitting for Sam Demel (1-0), singled to right to make it 7-4.
"I'm trying to get a pitch up and hit it up the middle. That's the way it went tonight," said Drew who hit his first career walk-off home run, a two-run shot, off Hoffman and the San Diego Padres on April 25, 2007.
The Diamondbacks snapped a seven-game losing streak to Milwaukee.
Aaron Heilman pitched the 10th for his sixth save in 11 chances, but not without a scare.
With one out he gave up consecutive singles to Prince Fielder, Casey McGehee and Lorenzo Cain. Joe Inglett worked the count to 3-2 before flying out to center. Jonathan Lucroy grounded out to second to end the game.
With Milwaukee leading 4-3, reliever John Axford walked Reynolds and Drew to start the ninth. After a sacrifice to advance the runners, Gerado Parra had an RBI groundout to tie the game.
Axford said that the most frustrating part was the two walks.
"That's the first time, I think, all year I walked two guys in an inning," Axford said. "That's something I've been trying to avoid, the multiple walks."
The Diamondbacks did some avoiding, too. Like not swinging at bad pitches and getting themselves out.
"We got some timely hits and the walk situations were good, too, for us," Drew said. "Overall, everybody just did what they could do to get the win."
Axford noticed the plate discipline, too.
"They laid off some pretty decent pitches in there, a couple of curveballs they didn't even really hint at all," he said.
The short-handed Brewers were forced to scramble in the outfield as starters Corey Hart and Ryan Braun were out with injuries and Jim Edmonds, their top reserve, had been traded.
Hart, the right fielder, has a sore lower back, but he pinch-hit in the ninth and grounded out. Braun, the left fielder, had a left-wrist strain and contusion.
Hart came out of Sunday's game against Houston in the top of the sixth. He took part in batting practice, but told Brewers manager Ken Macha that he couldn't go.
Braun, who is day-to-day, got tangled up with Astros first baseman Brett Wallace in a play at the bag.
Alcides Escobar, a rookie shortstop who has made appearances at all three outfield positions this season, started for the first time in right. Inglett came off the bench to play left.
The NL Central-leading Cincinnati Reds acquired Edmonds on Monday for outfielder Chris Dickerson who didn't arrive until late and was ready to pinch hit when Lucroy ground out to end the game.
Cain, playing for Carlos Gomez, who is on the 15-day disabled list with a concussion, made his third start in center after being recalled on Friday from Triple-A Nashville.
Diamondbacks starter Ian Kennedy hit three batters in the first three innings, but home plate umpire CB Bucknor didn't issue a warning until Milwaukee starter Chris Narveson threw behind Rusty Ryal in the fourth.
Kennedy has struggled with his control which may have explained why the Brewers, who lead the majors with 60 hit by pitchers, didn't retaliate. He leads the staff with nine hit batters and 13 wild pitches, including two in the game that turned into runs for Milwaukee.
After Cain bunted his way on in the second, Kennedy nailed Lucroy and Escobar above their right elbows. Cain later scored on a wild pitch as Milwaukee went ahead 2-1.
Chris Young led off the Diamondbacks' third with his 20th home run, but the tie didn't last long as Kennedy's wildness got him again in the bottom of the inning.
First, he hit Fielder and then walked Cain. Both advanced on a wild pitch before Inglett's sacrifice fly scored Fielder. Narveson singled home Cain as Milwaukee led 4-2.
Fielder's run-scoring single with two on in the Brewers' half of the first got the run right back after Kelly Johnson singled and took third on Justin Upton's soft liner and scored on Miguel Montero's single.
Upton walked and scored on a double play in the sixth as the Diamondbacks pulled within 4-3.
Narveson allowed three runs and six hits over six innings. Zach Braddock and Kameron Loe pitched scoreless relief until Axford took over and blew his second save in 18 chances.
"We hung in there," Diamondbacks manager Kirk Gibson said. "Things weren't going very good early. We found a way to hang in there."
Braun was in the dugout wearing a medical brace on his left wrist. ... Last Wednesday, Kennedy allowed four runs and eight hits over four innings in a 7-2 loss to Washington. It was his shortest outing of his season. Against the Brewers, Kennedy allowed four runs and five hits over six innings. ... Arizona's Adam LaRoche pinch-hit in the ninth and struck out.