San Diego handed the Diamondbacks their fourth straight loss after Arizona had moved in front by a run through four innings.
The Padres eventually built a four-run cushion, but had to withstand a shaky ninth that included a three-run homer from Gerardo Parra.
Alonzo came up with two away and Jesus Guzman on first in the fifth inning. He hit a 2-2 pitch off Wade Miley (2-1) over the wall in right to give the Padres a 4-3 advantage.
Kyle Blanks added to the San Diego lead with an RBI single in the seventh and the Padres scored twice more in the eighth, one of those runs coming in on a double from Chase Headley.
Jason Marquis (3-2) collected the win with a six-inning start. He surrendered three runs on four hits with five walks and five strikeouts.
Brad Brach came on to start the ninth for the Padres and put two runners on base without recording an out.
Huston Street replaced Brach and retired the first two batters he faced before giving up the homer to Parra.
Street then claimed his seventh save by getting Martin Prado on a fly ball to center that ended the game.
Celebrity Breakups and divorces of 2014 [PHOTOS]