PHOENIX -- Add Nick Pivetta's Tuesday night performance to the long list of quality outings by Philadelphia starters this season.
Pivetta (7-9) scattered five hits, struck out six and walked one to get his first win in four starts.
"The guys really picked me up on defense," he said, "and we scored runs when we really needed them. I think the team really pulled together and made this happen today."
Pivetta had gone 2-6 in his 10 previous starts since June 1.
"I think the organization has continued to show a great deal of confidence in Nick Pivetta," Phillies manager Gabe Kapler said, "and this is Nick kind of rewarding the organization for its patience."
The Phillies, who blew a 2-0 lead in the ninth inning and lost 3-2 in 14 in a 4-hour, 38-minute game on Monday, led 5-0 after a four-run eighth.
"We know how to take a punch," Kapler said. "We took a punch last night and it was a hard one, but we bounced back again today. It is sort of the character of our club now. We get knocked down but we pop right back up."
Zack Greinke (12-7) allowed only Williams' solo homer on three hits in seven innings but lost his second straight, despite giving up a combined three runs in the two outings. He'd gone 7-0 in his previous eight starts. Greinke struck out four and matched his season high with four walks.
"It was all right," he said. "A little wild early and it got better as the game went on. I felt good the whole time but I just wasn't hitting the spots early."
Philadelphia is up by 1 1/2 games on Atlanta in the NL East and Arizona dropped out of first in the NL West, a half-game behind the Los Angeles Dodgers.
"Last night, that one hurt really bad," Williams said. "But it's baseball, you know."
The Phillies scored their second run on a bunt by Cesar Hernandez leading off the eighth when Arizona reliever Jake Diekman threw the ball away at first and, backing up the play, right fielder Steven Souza Jr. threw wildly to third.
It was uncharacteristic for an Arizona team that leads the majors with a .990 fielding percentage.
"Things broke down on us I the eighth inning," Diamondbacks manager Torey Lovullo said. "I know it wasn't pristine. We play a good brand of baseball here and we are going to address some of those concerns and make sure we don't do it again."
Pat Neshek pitched a scoreless ninth for his second save.
Paul Goldschmidt doubled in a run and another scored on third baseman Maikel Franco's fielding error in the eighth for Arizona but Eduardo Escobar grounded into the Diamondbacks' fourth double play of the night to end the inning.
Greinke, who had 25 walks all season entering the game, walked two in each of the first two innings and escaped both times.
But Williams hit the first pitch of the third just over the right field fence to put the Phillies up 1-0.
"I wasn't looking for a certain pitch," Williams said. "I was just looking for something up."
Greinke settled down from there.
But Arizona could get nothing going against Pivetta.
The Diamondbacks' Nick Ahmed hit into double plays to end the second and seventh.
Phillies: INF J.P. Crawford (broken left hand) could be activated for Wednesday's series finale, manager Gabe Kapler said, or the team could wait until after Thursday's off day.
Diamondbacks: CF Pollock was back in the lineup after two days off to rest his tired legs. Pollock made pinch-hit appearance in both of those games.
If not for the pesky Pittsburgh Pirates, the Milwaukee Brewers might be leading the National League Central, or at least running neck-and-neck with the first-place Chicago Cubs.
For the first time in a month, the Chicago Cubs will play after an off-day as they head into the stretch run of what they hope leads to their third straight National League Central Division title.
The New York Mets dinged Max Scherzer's Cy Young chances Thursday night.
Trevor Bauer will take the mound Friday night for the first time in more than a month as the Cleveland Indians host the Boston Red Sox in the first contest of a three-game series at Progressive Field.
Melisa Reidy-Russell has detailed allegations of abuse during her marriage to Addison Russell, which has led to the Cubs shortstop being put on leave by MLB.
DJ LeMahieu's not his team's biggest star, but he's been the glue of Colorado's clubhouse. Still, amid a frenzied playoff chase, his future in Denver could be in doubt.