Jason Kubel hit two of Arizona's four home runs to help the Diamondbacks beat San Diego 8-5 Saturday night, snapping a seven-game losing streak against the Padres.

Aaron Hill and Justin Upton had solo homers as Arizona finished with 15 hits. Upton had a season-high four hits and Jake Elmore added two RBIs. The win moved the Diamondbacks 5½ games behind St. Louis for the second NL wild-card berth.

Kubel hit a two-run homer in the first inning. Hill led off the third with his 22nd homer before Kubel followed two pitches later for his career-high 29th home run. Upton connected off Miles Mikolas in the fifth inning on a line drive that carried 443 yards to straightaway center field for a 7-4 lead.

Rookie Wade Miley (15-9) won despite giving up five runs and eight hits in 5 1-3 innings. The left-hander struck out six and had three walks to snap his streak of 24 consecutive starts without issuing more than two walks.

J.J. Putz struck out the side in the ninth for his 29th save in 34 chances.

San Diego had outscored the Diamondbacks, 48-25 in during the seven-game win streak.

The Padres, who came in having won 13 of 17 games, lost at home for just the sixth time in 23 games.

Kubel broke out of a recent slump with his fourth multi-homer game this season. He was batting just .140 (6 for 43) in his last 14 games.

Both of Kubel's homers and Hill's home run came off rookie Casey Kelly (1-1), who only lasted into the third inning in his third major-league start.

Kelly, a prized prospect acquired by the Padres from Boston in the Adrian Gonzalez trade, was hit hard for the second straight start. The righty allowed six runs and eight hits in 2 1-3 innings.

After Kubel hit a two-run homer in the first, Jesus Guzman got San Diego even with a two-run double in the bottom of the inning.

Logan Forsythe hit a two-run homer for San Diego in the fourth to cut Arizona's lead to 6-4.

NOTES: Kubel has 10 multi-homer games in his career. ... Miley has given up more than three earned runs only six times in 25 starts. ... San Diego LF Carlos Quentin missed his second straight game and third this week with right knee irritation. ... Padres starting pitcher Clayton Richard was back with the team after his wife, Ashley, gave birth to a son. .. The series concludes Sunday with a pair of rookies throwing — Arizona LHP Patrick Corbin (5-6, 4.13 ERA) and San Diego LHP Andrew Werner (1-1, 3.00).