PHOENIX (AP) - The Arizona Diamondbacks had chances to win in the ninth inning, again in the 10th, and the next three innings after that.
After all those chances and more than 4 1/2 hours of baseball, David Peralta finally ended it with his first walk-off home run.
Peralta hit his second solo homer off the game off the top of the wall in the 14th inning and the Arizona Diamondbacks rallied from a two-run deficit in the ninth to beat the Philadelphia Phillies 3-2 on Monday night.
"I always wondered what it felt like to hit a walk-off homer," Peralta said. "It's something you can't even describe."
Phillies starter Jake Arrieta allowed three hits in eight scoreless innings, leaving with a 2-0 lead.
His chance at a fifth straight win came undone in the ninth.
Peralta hit a one-out solo homer off Seranthony Dominguez, and Steven Souza Jr. followed Eduardo Escobar's double with a tying single. Luis Garcia replaced Dominguez and walked two to load the bases, but got pinch hitter A.J. Pollock to ground out.
Yoshihisa Hirano (3-2) didn't allow a hit the final two innings, with Jorge Alfaro just missing a homer to right for the final out of the 14th.
The Diamondbacks kept putting runners in scoring position, but failed getting that crucial hit until Peralta hit the first pitch he saw from Austin Davis (1-2) off the wall and out in left-center. Peralta was mobbed at the plate after ending the Phillies' five-game winning streak with one swing.
"This is the type of baseball we were used to playing last year, done it in spurts this year and couldn't have come at a better time," Diamondbacks manager Torey Lovullo said.
Arrieta underwent a massive turnaround in July, going 4-0 with a 2.80 ERA in six starts after going 0-4 with a 6.66 ERA in June.
The right-hander is second in the NL at inducing groundball double plays with 19 and got another in the second inning to strand Escobar after a leadoff double.
Arrieta was lifted after 110 pitches and seemingly in great position, only to watch it go up in smoke with the ninth-inning blowup.
"He pitched great and we definitely strive to win baseball game like that for a starting pitcher who performs like Jake did," Phillies manager Gabe Kapler said.
Arizona's Zack Godley matched Arrieta nearly pitch for pitch until Odubel Herrera hit a run-scoring triple in the seventh inning and Jorge Alfaro followed with a sacrifice fly.
Godley allowed two runs on five hits and struck out seven in 7 1/3 innings.
After Dominguez gave up the two runs in the ninth, Kapler did not hesitate to bring him out. The right-hander has 12 saves this season, but has been struggling of late and Kapler didn't want to take a chance the game would end in the ninth.
"This is not his best. I am not blind," Kapler said. "I understand the reality is he is not pitching his best right now, but we are not wavering in our confidence whatsoever. We can't wait to get him back out on the mound because we understand how good he is and the talent will prevail."
In the 13th inning, Lovullo faced a dilemma: Hirano was due up third, but Lovullo wanted him to come back to pitch the 14th to save his bullpen. Lovullo initially told Hirano not to swing, but then relented after the Japanese rookie pleaded.
Hirano had yet to have an at-bat in the majors and was 2 for 21 during his career in Japan, but nearly won the game before grounding out, sending a flare to right that landed just foul with a runner on second base.
"It would have been a monumental moment in Arizona Diamondbacks baseball," Lovullo said. "The fact that he made contact is a miracle, but it speaks volumes about what these guys are trying to do."
Diamondbacks: 3B Jake Lamb is expected to have left shoulder surgery on Aug. 15 to repair a frayed rotator cuff. ... Pollock did not start for the second straight game to rest his fatigued legs.
Diamondbacks RHP Zack Greinke is coming off his first loss in nine starts heading into Tuesday's game against the Phillies after giving up two runs in six innings of a loss to the San Francisco Giants. Phillies RHP Nick Pivetta allowed six runs in 2 2/3 innings in his only career start against Arizona.
More AP baseball: https://apnews.com/tag/MLBbaseball and https://twitter.com/ap_sports