SAN DIEGO -- Cory Spangenberg hit two homers in 312 minor league at-bats this season.

So what does the 6-foot infielder do in his fifth major league at-bat?

Spangenberg lined the first pitch he saw from Arizona reliever Brad Ziegler into the short porch at Petco Park for a one-out, pinch-hit, walk-off homer as the Padres defeated the Diamondbacks 2-1 Wednesday night.

It was Spangenberg's first major league homer.

"This is unbelievable," Spangenberg said a day after he made a memorable debut notable with a decisive two-run-single in a 4-1 Padres win over Arizona. "I dreamed of playing in the major leagues, but I never dreamed of hitting a walk-off homer."

Ziegler (5-3) entered the game in the bottom of the ninth with the scored tied 1-1. He immediately retired Rymer Liriano on a liner to right.

That brought up the 23-year-old Spangenberg, the 10th overall pick in the 2010 draft who hit .331 with Double-A San Antonio this year despite missing half the season with his second concussion in less than two seasons.

Spangenberg came to the plate as a pinch hitter for center fielder Cameron Maybin on a hunch by Padres hitting coach Phil Plantier.

"Phil felt pretty good about Spangy, and Maybin didn't have great success against Ziegler," Padres manager Bud Black said. "Spangy's a slasher who likes the ball down and away."

However, Ziegler threw a slider up, and Spangenberg turned on it and put it out of the park down the right field line.

"That ball was well-struck," Black said. "It carries out of most parks."

Ziegler said, "This sucks. The team fought hard. (Starter) Wade

(Miley) pitches his butt off to get us there, and Evan (Marshall) was incredible to get us out of the eighth. It's just frustrating that I didn't make a good pitch.

"I wanted to keep the ball down and be aggressive. I was trying to go down and away, and I threw it mid-thigh on the inner third."

Padres reliever Kevin Quackenbush (3-3) got the win after throwing a scoreless top of the ninth.

San Diego (66-71) earned its sixth victory in its past seven games and improved their record at Petco Park to 21-6 since June 29.

Starting pitchers Miley of the Diamondbacks and Odrisamer Despaigne of the Padres departed after seven innings with the score tied 1-1.

Miley allowed seven hits and two walks with five strikeouts. He also picked two Padres off first. Despaigne allowed four hits and no walks with four strikeouts. He picked one runner off first.

The Diamondbacks used three singles in the top of the fourth to snap a scoreless tie.

Back-to-back hits to start off the inning by second baseman Cliff Pennington and right fielder David Peralta put runners at first and third. Despaigne struck out first baseman Mark Trumbo, but catcher Miguel Montero flared a single to center to drive in Pennington.

The Padres tied the game in the bottom of the fifth.

Catcher Rene Rivera opened with his second single to end a run of eight consecutive outs recorded by Miley. Liriano doubled into the right field corner to move Rivera to third. After Maybin struck out, shortstop Alexi Amarista drove Rivera home with a single to right.

Back-to-back singles by third baseman Yangervis Solarte and left fielder Abraham Almonte put Padres at the corners with no outs in the eighth, but Marshall proceeded to strike out the side.

NOTES: The Diamondbacks activated OF A.J. Pollock (fractured right hand) and INF Chris Owings (left shoulder strain) from the 15-day disabled list. Further September call-ups could come after Triple-A Reno and Double-A Mobile complete postseason play. ... The Padres added four more players to their roster: RHPs Joe Wieland and R.J. Alvarez, LHP Frank Garces and C Adam Moore. Because Moore and Alvarez had to be added to the 40-man roster and Wieland had to come off the 60-day disabled list, the Padres made three other moves. 3B Chris Nelson and LHP Troy Patton were designated for assignment, and INF Ryan Jackson was promoted from El Paso and transferred to the 60-day DL with a wrist strain. In addition, the Padres brought in RHP Matt Wisler from El Paso for a recon assignment. Wisler, 22, was not activated or added to the 40-man roster.