The margin of error was small for Padres pitcher Cory Luebke, and Arizona took full advantage.
Luebke allowed three home runs to the free-swinging Diamondbacks, including a pair of solo shots by Justin Upton, as Arizona handed San Diego a 4-3 loss Wednesday night.
Xavier Nady added a two-run homer off Luebke in the seventh inning that put the Diamondbacks ahead to stay, 4-2.
The three home runs equaled Luebke's season total through five starts and 29 appearances out of the bullpen covering 68 innings.
"You know Upton's hot going in," Luebke said. "He was a guy I couldn't let beat me."
But Upton's second homer only tied the game at 2 in the sixth. Luebke was most upset by the leadoff walk to Miguel Montero that preceded Nady's homer.
"It ended up being the difference in the game," Luebke said. "Lefty on lefty, I have to be able to get him."
Luebke also had his first major league hit with an infield single in the fifth inning.
"I'd much rather have a win," he said.
Ian Kennedy (12-3) won his fourth straight start, limiting San Diego to two runs and four hits with nine strikeouts over six innings.
"Fastball command wasn't as good as I wanted it to be but my changeup was probably the best it's been in a while," Kennedy said.
Upton reached 20 homers this season and extended his hitting streak to eight games. The slugger also connected in a 6-1 victory Tuesday night in the series opener.
During his hitting streak, Upton is batting .567 (17 for 30) with four home runs and 15 RBIs.
"He's striking the ball well right now," Diamondbacks manager Kirk Gibson said. "He's kind of carrying us right now. I hope it can continue."
Nady hit his fourth homer of the year to send Arizona to its fourth straight win.
J.J. Putz pitched the ninth for his 22nd save in 26 chances. It was Putz's first appearance after missing 20 games with right shoulder tendinitis. He came off the disabled list Tuesday.
Luebke allowed four runs and six hits in six-plus innings. The rookie left-hander struck out six with one walk as he allowed more runs than in any of his previous five starts this season.
San Diego rookie catcher Luis Martinez made his first major league start memorable with his first hit, a solo homer in the seventh inning off Bryan Shaw to trim the Diamondbacks' lead to 4-3.
Arizona has won eight of 12 since the All-Star break to remain three games behind first-place San Francisco in the NL West.
The Padres lost for the fifth time in six games to fall a season-high 15½ games out of first.
Upton added to his home run barrage in spacious Petco Park with a deep drive leading off the fourth inning that carried to the back of the San Diego bullpen in center field before bouncing out into the picnic section.
Will Venable gave the Padres a short-lived 2-1 lead with a two-run triple in the fifth. Upton tied the game with a 433-foot, two-out homer in the sixth into the third deck of the brick Western Metal Supply Co. building in left field.
It was Upton's fourth career multihomer game and his first since June 21, 2010, against the New York Yankees.
Nady, a second-round draft pick of San Diego in 2000, put the Diamondbacks ahead for good in the seventh after Miguel Montero drew a leadoff walk.
NOTES: Arizona leads the NL with 118 home runs. ... Sean Burroughs, the Padres' No. 1 draft pick in 1998, faced his old team for the first time and struck out as a pinch-hitter in the seventh inning. ... San Diego C Rob Johnson did not start after leaving Tuesday night's game with a bruised right hand after taking a foul ball off the back of his hand. ... Diamondbacks LF Gerardo Parra (sore left wrist) missed his third straight start.