Anaheim, CA (SportsNetwork.com) - Will Middlebrooks hit a two-run homer and drove in three runs, helping the San Diego Padres beat the Los Angeles Angels 5-4 in the rubber match of a three-game series.

Justin Upton and Matt Kemp each hit RBI singles in the seventh for the Padres. Andrew Cashner (2-7) gave up three runs on eight hits while striking out six and walking one over seven innings. The right-hander picked up his first win since April 19 against the Cubs.

"I got my slider back to where I like it," said Cashner. "I thought I could have made better pitches but my defense picked me up."

Matt Joyce hit a solo homer for the Angels, who have lost four of five. Carlos Perez had two RBI.

Garrett Richards (4-3) allowed five runs -- three earned -- on eight hits with six strikeouts and two walks over 6 2/3 innings.

"Garrett kept battling but didn't have his best command," said Angels manager Mike Scioscia.

The Padres broke a 3-3 tie with a two-run seventh. Alexi Amarista walked and Austin Hedges reached base on Richards' fielding error. With two outs, Upton and Kemp hit back-to-back singles to plate a pair of runs.

Los Angeles cut the gap to one in the eighth. Mike Trout led off with a double, moved to third when Albert Pujols flied out and scored on Kole Calhoun's sacrifice fly.

Craig Kimbrel tossed a scoreless ninth for his 12th save of the season.

Each team scored once in the second inning. In the top half, Derek Norris hit a one-out double and scored on Middlebrooks' double to left.

Perez tied things with an RBI single in the home half. David Freese, who led off with a double, scored on Perez's infield hit.

The Padres took a 3-1 lead on Middlebrooks' two-run homer in the fourth. Cory Spangenberg reached on a fielder's choice and crossed the plate on Middlebrooks' blast to left.

The Angels got one run back in the bottom half. Chris Iannetta hit a two-out single and scored on Perez's double down the left-field line.

Joyce's solo homer in the sixth tied the score at three.

Game Notes

Los Angeles went 1-for-5 with runners in scoring position and stranded five ... The Angels acquired outfielder Kirk Nieuwenhuis from the New York Mets on Wednesday for cash considerations.