PHOENIX -- Andrew Chafin entered Tuesday as the National League leader in inherited run percentage and the Arizona reliever did his job in a key situation against Philadelphia.
Chafin (1-2) struck out sluggers Rhys Hoskins and Bryce Harper with the bases loaded in the sixth inning, and the Diamondbacks rallied for an 8-4 victory.
"Huge moment there," Diamondbacks manager Torey Lovullo said. "Two proven guys that are run producers. It was the right guy in the right situation that kept the score right there. Andrew's been doing that a lot for us. You feel the energy after that moment."
Eduardo Escobar and Alex Avila both homered and drove in three runs and David Peralta also homered for Arizona, which has won three of four as it fights for a National League wild-card spot.
Chafin was allowing a mere 8.6 percent of his inherited runners to score. After his big outs Tuesday, the Diamondbacks scored five runs off Phillies relievers Ranger Suarez and Blake Parker and turned a 3-2 deficit into a comfortable lead. Suarez (3-1) took the loss.
Mike Leake, in his Diamondbacks debut after being acquired in a trade with Seattle on July 31, allowed two earned runs on 11 hits. The Diamondbacks won despite committing three errors, two by first baseman Christian Walker.
Philadelphia's Jake Arrieta left with a lead, charged with two runs on five hits with five strikeouts in five innings. Adam Haseley had a career-high three hits for the Phillies and drove in two runs, and Jean Segura added three hits.
It didn't start well for Leake, who played in college at nearby Arizona State. Corey Dickerson ripped Leake's third pitch of the game into the overhang in right center field for his seventh career leadoff homer.
Nick Ahmed's attempt to throw out Segura on a grounder wide of shortstop resulted in a two-base error in the fourth inning, and Segura came home on Haseley's single for a 2-0 lead.
The Diamondbacks drew even at 2 in the bottom of the fourth. Ketel Marte led off with a single — his National League-leading 139th hit of the season — and scored on Escobar's home run to right field.
Harper's diving catch in the bottom of the fifth with runners on second and third prevented at least one run from scoring on Marte's blooper to shallow right field. Arrieta got out of the inning unscathed with a 3-2 lead.
"Second and third, one out in the fifth and made some really good pitches with the changeup," Arrieta said. "Yeah, I would have liked one more (inning) but they decided to pinch hit for me."
Harper had a chance to add to the Phillies' lead in the sixth, but struck out swinging against Chafin to end the inning. The Phillies left 10 men on base.
"Heater, heater, heater, slider," Chafin said of the Harper at-bat. "That's what (catcher Avila) threw down. I felt comfortable making those pitches and that's what we did."
Phillies manager Gabe Kapler said players at times try too hard to get a big hit.
"Sometimes when you're not able to break the game open a couple of times in a row, several days in a row at times, you start to add a little pressure to your shoulders," Kapler said. "It's important to breathe, relax and just take your 'A' swing."
Avila singled with the bases loaded off Suarez in the bottom of the sixth to drive in two and give the Diamondbacks the lead for good. Escobar's RBI single in the seventh made it 5-3 before Peralta's 10th home run sailed high into the right field seats.
Diamondbacks outfielder Jarrod Dyson was ejected with two strikes on him in the bottom of the eighth, his first career ejection. He argued with home plate Tom Hallion over a called strike and had a heated exchange before leaving the field.
Arrieta's quick reflexes helped him catch Dyson's line drive up the middle in the third inning, which turned into a double play when Avila was caught off first base.
Phillies: OF Jay Bruce could be back at some point during the Phillies' series at San Francisco later this week. He's been on the 10-day injured list with a strained right oblique since July 17.
Diamondbacks: 3B Jake Lamb was back in the lineup after landing hard on his shoulder trying to get to a ground ball past third base Monday night.
Phillies: LHP Jason Vargas (6-5, 3.93 ERA) faces the Diamondbacks in his second start since being traded from the New York Mets on July 29. Vargas is 2-3 with a 6.82 ERA in six career starts against Arizona and is two wins away from 100 his career.
Diamondbacks: RHP Zac Gallen (1-3, 2.72) makes his Arizona debut after coming over in a trade with the Miami Marlins on July 31. He's allowed two runs or fewer in six of seven starts this season.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports