SAN DIEGO (AP) -- The ball was flying out of Petco Park like never before on Wednesday night, helping the Arizona Diamondbacks get back on track even as the San Diego Padres made some history.
David Peralta hit a leadoff homer and added a go-ahead double in the seventh for the Diamondbacks, who scored 11 runs in the final four innings and overcame rookie Hunter Renfroe's three homers as the NL wild card leaders beat the Padres 13-7.
The Padres, who blew a 6-2 lead, hit five home runs. Renfroe had his first career three-homer game and tied Nate Colbert's club record for rookies with 24. Renfroe became the first Padres rookie to hit three home runs, and the seventh San Diego player overall to do it.
The nine home runs were the most ever in a game at Petco Park, which opened in 2004.
The Diamondbacks hit four homers in avoiding a three-game sweep. They scored four times in the sixth to tie it, including a two-run homer by J.D. Martinez, and went ahead in the seventh. Chris Herrmann singled with one out off Craig Stammen (2-3) and scored the go-ahead run on Peralta's double to center.
A.J. Pollock hit a three-run homer in the four-run ninth, his 13th. All four runs were unearned due to an error by shortstop Erick Aybar.
"I've never seen the ball fly like it's flying here tonight," Martinez said. "That took me back a little bit."
There already have been a record number of homers in the majors this season.
"I think the game has adapted," Martinez said. "Pitchers are always ahead of hitters; I think hitters are starting to catch up with pitchers. You don't see too many sinker guys anymore. Everyone wants to throw four seamers. Everyone wants to throw the ball up. If you throw the ball up, that ball's going to get hit.
"Hitters have made the adjustment. They've learned that the ball in the air is more valuable than a ball on the ground."
Of course, he homered on a fastball up.
The Diamondbacks' first three home runs were off rookie starter Dinelson Lamet. Martinez's two-run shot in the sixth pulled them into a 6-all tie after they trailed 6-2. It was his 24th with the Diamondbacks and 31st overall.
Peralta homered to left-center on the game's second pitch, his 14th, and Jake Lamb connected with one out in the second, his 28th.
Jimmie Sherfy (2-0) pitched one inning for the win.
Rocky Gale and Christian Villanueva hit their first career home runs for San Diego.
The five homers gave the Padres 181, setting a franchise single-season record. They have a record 85 at Petco Park this season, breaking the old mark of 83 set last year. The downtown ballpark opened in 2004.
Renfroe hit a two-run homer in the third, a leadoff shot in the fifth and a solo drive in the ninth. It was the fourth career multihomer game for Renfroe, who made his big league debut late last season, and third this year. He was recalled Monday from Triple-A El Paso, where he'd spent a month working on his swing.
"That last one was the best, probably," Renfroe said. "Little curveball, slider thing in the zone. Kind of hung there. Got a little more barrel than the other ones. It was the first time in my professional career to get three, so obviously it's a really cool moment, and hope to do it again."
Villanueva, who made his first big league start Monday night, got his first hit when he singled with one out in the second. Gale, 29, who's spent almost his entire career in the minors, followed with a two-run homer off the lower balcony on the Western Metal Supply Co. brick warehouse in the left-field corner. He had a big smile on his face as he rounded the bases.
Gale also was called up Monday. He's making his first appearance in the big leagues since 2015, when he played in 11 games with the Padres. He had made one previous start, on Sept. 30, 2015, when he got his first and, until Wednesday night, only major league hit.
"It was awesome. I can't believe how much emotion I felt in that moment," Gale said. "I couldn't believe it. I was surprised. I think I screeched when I hit first base. I'm glad they didn't have a mike on me."
Diamondbacks: After a day off, RHP Zack Greinke (17-6, 2.87 ERA) is scheduled to start the opener of a three-game home series against Miami on Friday night. He is 3-0 with a 1.56 ERA in his last six games.
Padres: LHP Clayton Richard (7-14, 4.82) is scheduled to start Thursday night in the opener of a four-game home series against Colorado, which has a tenuous grip on the second NL wild-card spot. Richard agreed Wednesday to a $6 million, two-year contract that runs through 2019. The Rockies will counter with Tyler Anderson (5-5, 5.28).