PHOENIX -- Pittsburgh right-hander Trevor Williams turned his second home into a destination spot on Sunday.

Williams, who pitched at nearby Arizona State, gave up one run in a career-high five innings to help the Pirates break a six-game losing streak in a 4-3 victory over the Arizona Diamondbacks at Chase Field on Saturday.

Andrew McCutchen had an RBI double and pinch hitter John Jaso singled home a run in support of Williams, who made his second start since replacing Jameson Taillon in the rotation.

"It's always the next guy up around here," McCutchen said.

"He located his secondary pitches, and that's what you need to be able to do to have some success in this game. It was good to watch."

Williams (2-2) gave up four hits and one run, on the first of Nick Ahmed's two homers, in five innings. He struck out four, walked one and retired the final 12 he faced after Ahmed homered and Jeff Mathis followed with a double to open the second inning.

The Pirates (15-22) had lost eight of 10.

"He just pitched," Pittsburgh manager Clint Hurdle said. "He's always been an old-time pitcher. Watch the way he rubs up the ball. I feel like I'm back in the '70s watching a pitcher rub up a ball. He's got that windup. For me it's tradition. It's an old-school windup. He used all four pitches. Only one walk."

Josh Harrison and McCutchen hit consecutive doubles off Taijuan Walker (3-3) for a 3-1 lead in the fifth inning and the Pirates scored on a double play grounder and an infield error in the fourth. Harrison had two hits.

Jaso, hitting for Willams, singled in a run in the sixth to make it 4-1.

Paul Goldschmidt homered in the eighth inning and Ahmed homered again in the ninth, but Tony Watson retired the final two batters for his eighth save.

Ahmed had his first career two-homer game and Mathis had two hits for Arizona (21-17), which at 15-7 has the best home record in the NL.

"I feel good, healthy," said Ahmed, who missed the final two months of last season because of a hip injury.

"Getting strong and getting consistent at-bats obviously helps. I feel like I am having good at-bats. Just trying to out the ball in play and hit it hard consistently and swing at the right pitches and not try to do too much."

Ahmed hit the first pitch in the second inning down the left field line and into the Arizona bullpen for his third homer of the season. It was 1-0.

Pittsburgh took a 2-1 lead in the fourth inning despite getting only ball out of the infield. Gregory Polanco hit a broken bat dribbler down the third base line for a single and David Freese followed with a single that ricocheted off Walker's left shin and into right-center as Polanco took third.

Josh Bell walked to load the bases before Francisco Cervelli hit into a double play as the tying run scored. After Jordy Mercer was walked intentionally, Williams reached when second Brandon Drury mishandled his routine error and Freese scored.

"A swinging bat is a dangerous bat," Hurdle said.

Williams, who tied for the NCAA Division I lead with 12 victories at Arizona State in 2013, pitched in front of 10-15 family members and friends from San Diego and suburban Scottsdale.

He gave up seven hits and eight runs, six earned, in three innings in a loss to the Dodgers in his first start on the trip Monday.

"That's not me," Williams said. "That's not a Trevor Williams outing. I'm glad I was able to come back five days later and get back on the right track."

NOTES: Arizona C Chris Iannetta took several stitches in a split upper lip and also suffered fractured teeth and a fractured nose, Arizona manager Torey Lovullo said, when he was hit in the mouth with a fastball in the seventh inning Friday. A CT scan was negative, Lovullo said, although Iannetta is still being evaluated. ... Cyclist Lance Armstrong is among those who have sent words of encouragement to Pirates RHP Jameson Taillon after his diagnosis of suspected testicular cancer. Armstrong was diagnosed with a sub-type of testicular cancer called embryonal carcinoma in 1996 and started the Livestrong Foundation after his recovery. ... Players on each team wore pink-billed caps and swung pink bats in honor or Mother's Day on Sunday.