Phillies closer Seranthony Dominguez took the mound to close things out and at that point in the game, Peralta was 0-for-3 with a strikeout.
Peralta managed to hit a one-out homer, and two batters later, Steven Souza Jr. tied the game with a single up the middle.
Fast forward to the 14th, and Peralta came to the plate against Austin Davis needing a triple for his first career cycle. Instead, he wound up with a walk-off homer when his drive to left-center bounced off the top of the wall and into the seats.
"That was my first walk-off homer," Peralta said. "I always wondered how it feels to hit a walk-off homer and it's something you can't describe. It's emotional. I was just trying to put the ball in play, do something, and he threw a slider and I had a pretty good swing. I knew it was hit pretty well, but it was the deepest part of the park, so to see the ball go out of the park, it was like a big relief."
Peralta finished the game 4-for-7, quite a difference from the first eight innings.
"You can't give up after the first two, three at-bats of the game," Peralta said. "You never know what's going to happen. You never know which at-bat that's going to be the one that you're going to do something for the team. You saw what happened my last four at-bats, I got a homer, a double, a single and another homer. It's not just me, it's the whole team. We never give up and the way we came back is pretty special."
With the win, the D-backs jumped one-half game ahead of the idle Dodgers for first place in the National League West.
"Peralta deserves some credit here," Phillies manager Gabe Kapler said. "He really swung the bat with authority. He's an excellent hitter and he put a good swing on the ball and drove it out to the opposite field. He did a good job."
The D-backs had plenty of chances to score before the 14th as they stranded seven runners through the first four extra innings, but they weren't able to push across a run.
The good news for Arizona was that the Phillies' offense went quiet in extra innings, failing to get a hit after the ninth inning.
MOMENTS THAT MATTERED Needed the cushion: Already up, 2-0, in the top of the ninth, it looked like the Phillies were going to gain even more of a cushion when Odubel Herrera and Maikel Franco led off the inning with singles. D-backs right-hander Matt Andriese struck out Jorge Alfaro and got pinch-hitter Andrew Knapp to ground into an inning-ending double play.
"Any time you have an opportunity to tack on an additional run or two, you go for it," Kapler said. "It's a kill shot in those situations and we weren't able to scratch across and additional run."
ROSTER MOVE Following the game, the D-backs reinstated infielder Deven Marrero from the 10-day disabled list and designated him for assignment. Marrero had been on the DL since June 29 with a left oblique strain. He slashed .167/.224/.205 for the D-backs in 49 games.
MITEL REPLAY OF THE DAY Alex Avila led off the third by drawing a walk from Arrieta and Zack Godley followed with a sacrifice-bunt attempt. Alfaro jumped out from behind the plate, pounced on the ball and threw to second to try and nail Avila. Second-base umpire C.B. Bucknor called Avila safe, but the Phillies challenged the call and after a brief review, the call was overturned and Avila was called out.
UP NEXT The D-backs continue their series against the Phillies on Tuesday night with ace Zack Greinke (12-6, 2.96 ERA) on the mound. Greinke has been on a roll of late, going 7-1 with a 1.68 ERA in his last nine starts. He has allowed two or fewer runs in his last eight starts. Greinke will be opposed by right-hander Nick Pivetta (6-9, 4.75). First pitch is set for 6:40 p.m. MST.