PITTSBURGH -- Neil Walker was looking for a pitch to drive, and he found one.
Andrew McCutchen hit a leadoff drive in the first and finished with two hits for Pittsburgh, which has won five of its last six home games. The majors' worst team earned its first three-game sweep since May 4-6 against the Chicago Cubs.
"It's definitely been a long while," McCutchen said. "Walker delivered in a big way and put us up. It was good just to be there and be a part of it and just to not give up, keep fighting and get those three wins and sweep."
|More on Pirates|
Pittsburgh (51-98) remains two losses away from its first 100-loss season since 2001 but managed to pick up its first sweep of any kind since taking both games from the Cubs from May 31-June 1.
Jose Tabata hit a run-scoring fielder's choice to cut Arizona's lead to 3-2 before Walker connected against Aaron Heilman (5-8), hitting a drive to center for his 12th homer.
"I was thinking to just try to hit one in the gap somewhere and possibly get a chance to score Jose," said Walker, who had two homers and five RBI in the series. "And instead I was fortunate enough to get one in the air and hit one on the barrel.
"We know we're not going to make the playoffs but situations like these can bring teams closer together."
Joel Hanrahan (4-1) struck out both batters he faced in the eighth, and Evan Meek worked a perfect ninth for his third save.
Ryan Roberts homered for the last-place Diamondbacks, who wasted a great start by rookie Daniel Hudson. They completed a 2-8 road trip and have dropped 12 of 15 overall.
Arizona also had a 3-2 lead in the seventh inning of the series opener Friday night, and lost that one 4-3.
"We've had a tough road trip where we've wasted several efforts," manager Kirk Gibson said. "Especially two of them here."
McCutchen hit Hudson's first pitch over the wall in straightaway center but that was it for the Pirates against the right-hander, who allowed three hits in 6 1/3 innings.
"A guy jumps on a first-pitch fastball, it's nothing to really hang your head about," Hudson said. "It's the first pitch of the game; you've still got to go out there and get the next couple guys out and put a couple zeros up after that."
Adam LaRoche and John Hester had RBI doubles in the fourth, giving Arizona the lead, and Roberts went deep with one out in the eighth, chasing Pirates starter Zach Duke.
Pitching perhaps to keep his turn in the rotation -- and, in a larger sense, for a shot at a 2011 roster spot with the Pirates -- Duke had his best outing in five starts. Duke was tagged for 11 earned runs in 4 1/3 innings over his previous two starts, but allowed six hits and a walk in this one.
"I've had a couple bad starts before," Duke said. "There's a mental battle all the time, that's part of the job, so I'm prepared to deal with it. It's nothing new. ... To get a win, that's the main thing."
McCutchen's drive was his 16th of the season, and third in his past five games.
"We're still playing hard," Pirates manager John Russell said. "They're bouncing around and the attitude's really good. That's a good sign for a young team. They're not just waiting for that last day of the season. I think a lot of them wish we could continue to play -- and that's a good thing."
Diamondbacks OF Justin Upton was not in the lineup for the 15th time in the past 17 games due to left shoulder soreness. ... The sweep was the fourth by the Pirates this season. ... Pittsburgh entered this series having lost four straight and seven of eight.