PHOENIX (AP) -- Arizona's bullpen was depleted, its players tired after a 14-inning game the night before.
What the Diamondbacks needed a long and strong outing from Wade Miley.
The left-hander didn't look as if he'd be able to give it to them early, but sure finished strong.
Miley pitched eight effective innings after a shaky start and Martin Prado lined a two-run single in the eighth inning, helping the Diamondbacks end a three-game losing streak with a 5-3 win over the Milwaukee Brewers on Thursday night.
''We had to stick with him, we didn't have a lot of length out in the bullpen,'' Diamondbacks manager Kirk Gibson said. ''We just wanted him to hang in there.''
The Diamondbacks were a bit thin on pitchers for the series opener after using eight in Wednesday night's 7-5, 14-inning loss to the Dodgers. They also figured to be a bit tired following the five-hour game that ended after midnight.
Miley (6-7) didn't look as if he'd be much help, giving up a pair of homers in the first three innings.
After those early mistakes, he started settled into a rhythm and so did the Diamondbacks' offense after struggling early against Brewers starter Yovani Gallardo
Adam Eaton helped Arizona close to 3-2 with a two-run triple in the fifth inning, Jason Kubel tied it with a sacrifice fly the next inning and Prado capped the comeback with the bases loaded against Jim Henderson (3-3) in the eighth.
Brad Ziegler worked around two baserunners in the ninth to earn his second save, a night after Heath Bell blew a save with two outs in the ninth in the loss to the Dodgers.
''Everybody knows what happened last night and I was just trying to go as deep as possible,'' Miley said. ''I was fortunate that I started feeling better at the game went along, got into a better rhythm and get through eight.''
Milwaukee jumped on Miley early, going up 3-0 on a two-run homer by Jonathan Lucroy and a solo shot by Carlos Gomez.
The Brewers managed one hit off him the rest of the way and went 1-for-7 with runners in scoring position to kick off the four-game series with a loss.
''We did have a chance to get him early,'' Brewers manager Ron Roenicke said. ''What it really comes down to his they got a big hit and we didn't. We had a couple of chances and we didn't get big hits.''
Miley gave up four hits in the first inning, a long two-run homer by Lucroy. He left another pitch up in the third and Gomez hit it out for a solo homer that put the Brewers up 3-0.
Miley settled down after that, retiring 13 straight batters - with help from a diving catch by Gerardo Parra in right in the seventh inning - until Aoki led off the eighth with an infield single.
Miley allowed three runs and eight hits.
Unlike the night before, when Bell had Arizona's 19th blown save of the season, the Diamondbacks closed it out.
Ziegler hit leadoff hitter Richie Weeks and gave up a single to Juan Francisco, but got the final two outs with runners on the corners to finish it off.
''It was huge, gives a couple of guys some days off and rest mentally, physically, everything,'' Miley said. ''It was huge for him to get those three outs.
Brewers starter Yovani Gallardo has dominated the Diamondbacks during his career, going 6-0 with a 1.62 ERA in eight career starts before Thursday.
He was sharp early against Arizona again, getting the Diamondbacks to pound balls into the ground while holding them hitless until Paul Goldschmidt's one-out single in the fourth inning.
The Diamondbacks strung together a couple of hits in the fifth inning and Eaton, playing his third game since coming off the DL, reached down for a two-run triple for his first hit of the season.
Kubel tied it with a sacrifice fly off Gallardo in the sixth inning.
Gallardo allowed three runs and four hits in six innings.
''I got into trouble on my own,'' Gallardo said. ''I tried to do too much and tried to make the perfect pitch and get out of it then the next thing you know the ball is up instead of trusting my stuff. Trust what I was doing in the earlier innings.''
NOTES: Brewers LF Ryan Braun, who was expected to return to the lineup after missing a game with a sore thumb, will be out at least three games on bereavement leave. The Brewers said he left the team to attend to a family medical issue. ... Arizona 2B Aaron Hill was 0 for 4, the first time in 13 career games against Milwaukee he's failed to get a hit. ... Arizona LHP Patrick Corbin will make his first start since being chosen for the NL All-Star team in the second game of the series Friday night. He is the fourth Diamondbacks pitcher to win 10 games before the All-Star break, first since Brandon Webb went 13-4 in 2008. ... Brewers LHP Tom Gorzelanny will start against Arizona on his 31st birthday. He allowed two runs in six innings of a 2-1 loss to the Mets on Sunday.