PHOENIX — This time, Trevor Williams looked like he belonged in the Pittsburgh Pirates' rotation.

Pitching just down the road from where he played collegiately at Arizona State, Williams threw five strong innings and the Pirates snapped a six-game losing streak with a 4-3 victory over the Arizona Diamondbacks on Saturday night.

Nick Ahmed homered twice for the Diamondbacks, the second to make it a one-run game in the ninth. It was Ahmed's first career multihomer game. Paul Goldschmidt also homered for Arizona.

Pirates manager Clint Hurdle said it's been important not to overreact during this rough stretch.

"I've been fortunate to be in the game 43 years. I know a lot of things don't work — manage like your hair's on fire, overplay everything, overreact to things," he said. "These are men. They've got to play. They've got to figure things out on their own."

Williams (2-2), in his second start since taking the rotation spot vacated when Jameson Taillon left to begin treatment for testicular cancer, gave up a run on four hits, striking out four and walking one.

Williams retired the last 12 batters he faced.

He had been hit hard for eight runs in three innings against the Dodgers in Los Angeles on Monday night. But the only run he allowed Saturday was Ahmed's leadoff homer in the second.

Williams said he told himself to forget about that outing.

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

Williams, called "an old-school" pitcher by Hurdle for his windup and the way he rubs up the ball, threw three pitches or fewer to batters eight times.

"The game demands execution," Hurdle said. "At the end of the day, you have to execute to win. We executed better than them today. They made a couple of mistakes on their side of the ball. We scored two runs without an RBI."

Tony Watson, coming off his first blown save of the season, survived a scare to get his eighth save in nine tries.

He gave up Ahmed's homer with one out in the ninth but got Jeff Mathis to fly out to centre.

Pinch-hitter Daniel Descalso walked and A.J. Pollock's broken-bat pop out to third ended the game.

"We all thought something magical was going to happen," Arizona manager Torey Lovullo said, "but unfortunately it didn't."

Taijuan Walker (3-3) gave up four runs, three earned, on eight hits in six innings to take the loss, only the seventh at home for the Diamondbacks in 22 games.

Andrew McCutchen had a run-scoring double and John Jaso a pinch-hit RBI single for the Pirates.

Both players had been off to slow starts at the plate.

"He left a curveball up," McCutchen said. "I finally got something up in the zone and was able to do some damage to it."

The game was played without incident a night after Arizona's Chris Iannetta was hit in the face with a fastball from Pittsburgh's Johnny Barbato.

Pittsburgh took the lead in the fourth. The Pirates loaded the bases with no outs and tied it at 1-1 when Francisco Cervelli bounced into a double play. Jordy Mercer was walked intentionally to bring up Williams and second baseman Brandon Drury booted a routine grounder to allow the Pirates to go up 2-1.

The Diamondbacks, at 15-7, still have the best home record in the National League.

IANNETTA'S INJURIES

Iannetta has several stitches in his upper lip, plus a couple of fractured teeth and a broken nose after getting hit in the face by a fastball. Tests for a concussion were negative but Lovullo said Iannetta would be monitored closely. There's been no decision on whether to put him on the 10-day disabled list, the manager said.

But he won't be rushed back.

"The obvious concerns are, being a catcher and the mask, foul tips, just ripping open wounds," Lovullo said, "so we're going to take our time with this one."

Arizona has two other catchers — Mathis and Chris Herrmann.

UP NEXT

RH Ivan Nova (3-3, 2.23 ERA) takes the second-best ERA in the National League to the mound to try to give the Pirates a split of their four-game series in Arizona. LHP Robbie Ray (2-3, 4.14) goes for the Diamondbacks. He's fourth in the NL in strikeouts.