Updated

Neil Walker hit a two-run homer in Pittsburgh's three-run eighth inning and the Pirates beat the Arizona Diamondbacks 4-3 on Sunday to complete a three-game sweep.

Andrew McCutchen hit a leadoff drive in the first and finished with two hits for Pittsburgh, which has the worst record in baseball but has won five of its last six home games. The Pirates earned their first three-game sweep since May 4-6 against the Chicago Cubs.

Jose Tabata hit a run-scoring fielder's choice to cut Arizona's lead to 3-1 before Walker connected against Aaron Heilman (5-8), hitting a drive to center for his 12th homer.

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 and have dropped 12 of 15 overall.

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.

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.

McCutchen's drive was his 16th of the season, and third in his past five games.

NOTES: 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, first since taking both games from the Cubs from May 31-June 1. ... Pittsburgh entered this series having lost four straight and seven of eight.