PITTSBURGH -- The late-inning comeback was exceptional, coming on the road in a tight NL West race during the final week of the season. The Arizona Diamondbacks' only problem was they couldn't finish it.
Pinch-hitter Josh Phelps singled in the go-ahead run with two outs in the eighth after Pittsburgh blew a four-run lead in the top of the inning, and the Pirates halted a nine-game losing streak by beating the Diamondbacks 6-5 on Tuesday night.
Arizona lost its second in a row after winning four straight and its NL West lead was cut to two games over second-place San Diego, which rallied with two outs in the ninth for a 6-4 victory at San Francisco.
"This is a tough loss, to come back like we did, a bunch of guys got a lot of big hits. It's a tough one," Eric Byrnes said. "This team has a lot of fight in it. It impresses me every night."
The Diamondbacks trailed 5-1 going into the eighth but scored four runs against three relievers to tie it. Chris Snyder's RBI double off Romulo Sanchez led to pinch-hitter Conor Jackson's two-run single and Stephen Drew's tying single, with those two hits against John Grabow.
"We battled back beautifully. Iit's a shame," manager Bob Melvin said. "I really felt like we were in a good position to win that game."
After Byrnes grounded out with runners on first and third to end the rally, Adam LaRoche doubled with one out in the bottom half and Phelps, in a 3-for-25 slump, singled between third and short against Brandon Lyon (6-4), Arizona's sixth pitcher.
Phelps balked LaRoche to third ahead of the single, but it is likely LaRoche would have scored even if he had been on second.
"I wasn't thinking about the balk," Lyon said. "I'm trying to keep the score tied."
Arizona, starting a six-game trip, is attempting to win its fourth division title in 10 seasons.
"I said this before, we're going to have to win this thing," Byrnes said. "Teams aren't going to give it to us. But the good thing is we still do have that lead."
Salomon Torres (2-4) got the victory by getting the final out. Matt Capps finished with a perfect ninth for his 18th save in 21 chances, and his first since giving up Scott Hairston's three-run homer in the ninth that rallied San Diego past Pittsburgh 5-3 last Wednesday.
"The last nine days have been very difficult for us," Pirates manager Jim Tracy said. "And we're going to try to come after them again tomorrow."
The Pirates avoided their second double-digit losing streak in as many seasons under Tracy. They had a modern-era club record 13-game losing streak in June 2006. Poor finishes are nothing new for the Pirates, who took what became an eight-game losing streak into the final week of last season but ended it by winning their final two games.
Ian Snell, making his final start of the season, limited Arizona to one run over six innings by stranding seven runners but did not figure in the decision.
Snell complained recently of having a slightly sore arm and, after pitching a career-high 208 innings, will be skipped over for what would have been his final start of the season Sunday. The right-hander allowed only six earned runs in 33 innings over five starts in September, a 1.64 ERA, giving up one run or no runs four times, and has a 3.76 ERA for the season despite a 9-12 record.
"There's nobody to blame -- baseball's a difficult game," said Snell, who is so encouraged by his season that he will ask his agent to seek a multiyear contract from Pittsburgh. "We play hard every day. This team's lost a lot of close games this year."
The Pirates took a 2-0 lead in the first as leadoff hitter Nyjer Morgan hit his first career homer, off Doug Davis, and Jose Bautista doubled and scored on a double play. Arizona's only run off Snell came on Augie Ojeda's two-out RBI single in the second. Ojeda reached base four times.
The score stayed 2-1 until the Pirates scored three runs in the seventh. Cesar Izturis hit a run-scoring double following two walks by reliever Tony Pena, and pinch-hitter Nate McLouth had a two-run single off Bill Murphy.
The Pirates halted the slide hours after hiring Neal Huntington as general manager.
- Davis failed to win for a fourth consecutive start, giving up two runs and five hits in five innings. He has a 7.27 ERA since beating San Diego 9-1 on Sept. 4.
- The Pirates, 36-40 at home, must sweep this six-game homestand to finish above .500 in PNC Park.
- Freddy Sanchez went 1-for-2 against Davis to finish 5-for-6 against him this season. Sanchez is 16-for-32 against him in his career. He left in the seventh with blurry vision.
- Arizona is 4-3 against Pittsburgh this season.
- Phelps has a .308 average (8-for-26) with eight RBI as a pinch-hitter.