PITTSBURGH (AP) -- Starling Marte swung so miserably at the first two sliders he saw from Arizona Diamondbacks closer Addison Reed in the ninth inning that the Pittsburgh left fielder knew more were on the way.
So he stepped out of the batter's box, took a deep breath and waited.
''I was struggling the first two pitches but I was thinking about the pitch I want,'' Marte said. ''He threw me a slider and it was a good chance to hit the ball.''
Was it ever.
Marte turned an 81 mph slider over the middle of the plate into a game-tying, two-run double and then scored on pinch-hitter Ike Davis' single two batters later as the Pirates rallied for a 3-2 win Tuesday night.
''Every time we're up to bat there's a chance we do something,'' Davis said. ''It's hard to shut us down for nine. We've done it a lot this year ... anything is possible with us.''
The Pirates were shut down for eight innings by Arizona starter Wade Miley before rallying in the ninth. Neil Walker and pinch-hitter Gregory Polanco started the inning with singles against Miley. One batter later, Marte turned an 0-2 count into a tie game.
''He got a ball that he could get a barrel on,'' Pirates manager Clint Hurdle said. ''He slowed it down and put a good swing on it and hit it to the big part of the ballpark.''
Andrew McCutchen was intentionally walked and Davis hit a broken-bat single to right, scoring Marte easily as the Pirates won for the fourth time in five games.
Ernesto Frieri (1-3) earned his first win with the Pirates after working a scoreless ninth.
The abrupt ending ruined an otherwise stellar outing for the struggling Miley, who is winless since May 10. The left-hander retired the first 14 batters he faced and allowed four hits in eight-plus innings, striking out 10. Despite the slender lead, Arizona manager Kirk Gibson didn't hesitate to send Miley back out for the ninth in search of his first career shutout.
Things changed quickly, however, when Walker and Polanco reached.
''I didn't make good pitches,'' Miley said. ''Actually, the pitch to Walker was a good one, a slider down and in, but I hung a pitch to Polanco. I was making pitches all night long but I didn't make them when I needed to.''
Until the late miscues, it appeared Miley was on his way to his first victory in nine starts. Miguel Montero and Aaron Hill produced consecutive RBI singles in the fifth off Pirates starter Jeff Locke. Paul Goldschmidt went 2 for 4 with a run for the Diamondbacks, who fell to 27-2 when leading after eight innings.
''I want to be the guy out there with the game on the line,'' Reed said after blowing his fourth save. ''Sometimes it doesn't go the way I want or my teammates want it to.''
Locke lacked Miley's crispness but allowed only two runs over eight innings, yielding eight hits while walking one and striking out three. The Diamondbacks stranded six runners in the first four innings and were on their way to doing it again in the fifth before catching a break thanks to some sloppy defense by the Pirates.
Goldschmidt singled with two outs and was attempting to steal second when the Pirates sniffed it out. Locke threw to Gaby Sanchez at first to start the rundown, but the burly Goldschmidt was safe at second when Sanchez's throw to shortstop Jordy Mercer sailed into left field.
Montero followed with a single that brought Goldschmidt home, and Montero scored moments later on Hill's flare to shallow right.
Given some room to work with, Miley didn't let it go to waste. He struck out the side in the seventh and had little trouble in the eighth.
Arizona nearly extended its lead to 3-0 in the ninth, only to have Gerardo Parra thrown out at home trying to score on a single to right by Ender Inciarte. Less than 15 minutes later, the Pirates were celebrating their second win in 35 games when trailing after eight innings.
NOTES: Pirates LHP Francisco Liriano is scheduled to pitch four innings in a simulated game Wednesday. Liriano, on the disabled list with a strained left oblique, threw 52 pitches without an issue in the bullpen on Sunday. ... An MRI on Arizona SS Chris Owings' left shoulder Monday revealed no structural damage. Owings went on the disabled list Sunday with a left shoulder strain. Gibson called the injury just a bruise. Owings won't hit for about a week, but Gibson is confident the rookie will be able to return when his 15-day stint on the DL is up, barring any setbacks. ... The series continues Wednesday when Arizona's Chase Armstrong (5-3, 3.63 ERA) faces Pittsburgh's Charlie Morton (4-9, 3.41).