SAN DIEGO -- To go yard, the San Diego Padres' Melvin Upton Jr. picked the deepest part of Petco Park.

"It is big out there, so I didn't know if it was going out," Upton said.

Upton's sixth homer of the season did get out beyond the right-center fence as his two-run blast in the ninth lifted San Diego past the Los Angeles Dodgers, 7-6, on Friday night.

Wil Myers had singled in shallow center, just beyond second baseman's Chase Utley's reach, before Upton's dramatic blow.

"I knew I hit it pretty good," said Upton, after the sixth walk-off homer of his career. "It was cool. We fought hard and it was a back-and-forth game. Our pitchers kept us in the game the whole time. Luckily, we found a way to pull it out."

Kevin Quackenbush (2-2) worked the ninth and got the win.

Kenley Jansen (1-1), who was trying to record a four-out save, absorbed the loss.

Jansen, who had never giving up a walk-off, exited the locker room before the media was allowed in and unavailable for comment.

"Tonight was a head-scratcher; I'll take that matchup any day," Dodgers manager David Roberts said. "Kenley has been lights out for us and we can't expect him to be perfect. Melvin put a good swing on that ball and took it out of the ball park.

"Going to Kenley was a no-brainer, we felt really good about. Then in the ninth inning there was a bloop hit and a homer. Knowing him I expect to have a lead tomorrow and use him again. I expect him to rebound."

The Padres beat the Padres for the first time in seven games and for only the third time in 13 games.

Justin Turner's two-run homer in the eighth off reliever Brandon Maurer had given the Dodgers a 6-5 lead.

"That was a fun Major League Baseball game," Padres manager Andy Green said. "It was fun for the fans, and certainly more fun for us being on the winning end."

Christian Bethancourt's two-run, pinch-hit homer in the sixth pushed the Padres ahead, 5-4. Bethancourt was in the original lineup, scheduled to make his first career start in right field. But after pre-game drills revealed Bethancourt was challenged to play the position, he was replaced in favor of Jose Pirela.

Bethancourt was called as a pinch-hitter after Adam Rosales walked. Bethancourt smacked the first pitch for a two-run blast off starter Scott Kazmir that traveled 406 feet, landing in the left field seats.

The Padres missed a chance to add on in the seventh with one out and runners on first and second. But Alexei Ramirez flied out and pinch-hitter Travis Jankowski grounded out.

Derek Norris' homer to start the fifth sliced the Padres' deficit to 4-3. That equaled the number of runs the Padres scored in the previous three games.

Yasiel Puig put Los Angeles ahead 4-2 when stroking a fifth-inning, two-run homer -- his fifth of the year. Trayce Thompson was aboard via a single.

The Dodgers tied it at 2 in the fourth on Yasmani Grandal's double, which followed Puig's inning-opening single. The Dodgers loaded the bases with two outs to chase Friedrich, but reliever Carlos Villanueva got groundouts on two well struck balls to escape further damage.

Corey Seager pulled the Dodgers to within 2-1 with a run-scoring double over Pirela's head in the third. Seager extended his career-high hitting streak to 11 games by scoring Enrique Hernandez, after he started the inning with a double. Friedrich rebounded to strand Seager by getting Howie Kendrick and Thompson on ground outs.

The Padres struck in the second, with an unlikely rally which led to a 2-0 lead.

Kazmir loaded the bases on a walk, hit batter, passed ball and intentional walk with two outs. That brought Friedrich to the plate and he looked overmatched early in the at-bat. Then Kazmir delivered a 92 mph belt-high fastball and Friedrich slapped it into center field for a two-run single -- the first two RBIs of his career.

"The hit to the pitcher is frustrating," Kazmir said. "And it's almost embarrassing to have seven walks in that many innings. It is unacceptable."

NOTES: Padres RF Matt Kemp, whose average has dropped to .238, didn't start and flied out as a pinch-hitter ... Jose Pirela, who has seen time with the Padres at second base, got his first start in right field. ... RHP Andrew Cashner (hamstring) will come off the disabled list next week and start Tuesday or Wednesday in San Francisco. ... Dodgers 1B Adrian Gonzalez (back) was out of the starting lineup, but flied out as a pinch-hitter. Manager Dave Roberts said he'll start Saturday. ... Roberts wasn't fazed about having a cleanup hitter in 2B Howie Kendrick with no HRs. "He gives us the best opportunity to drive in runs there," Roberts said.