PHOENIX (AP) — David 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.

The Diamondbacks had the winning run in scoring position in the ninth through 13th innings and couldn't get the hit they needed.

Peralta finally ended it, hitting 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' six-game winning streak with one swing.

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.

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.

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.

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.

Godley had been just as good over his last six starts, going 3-0 with 2.64 ERA. He got some double-play help in the second inning and had a stretch of four strikeouts in five batters between the fifth and sixth innings.

TRAINER'S TABLE

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.

UP NEXT

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