LOS ANGELES -- The Los Angeles Dodgers repelled two threats in the final two innings to defeat the Arizona Diamondbacks 4-3 on Friday night in front of 42,831 at Dodger Stadium.

The Dodgers took a 3-1 lead in the bottom of the seventh inning when first baseman Adrian Gonzalez singled to bring shortstop Hanley Ramirez home. But the Diamondbacks narrowed their deficit to one run in the top of the eighth and had a chance to tie the score against right-handed reliever Brian Wilson.

Catcher Tuffy Gosewisch's single scored second baseman Aaron Hill and sent third baseman Martin Prado to second base. But left-hander J.P. Howell relieved Wilson and struck out center fielder David Peralta before pinch-hitter Miguel Montero hit a long fly ball that center fielder Andre Ethier caught at the warning track.

Again, Los Angeles built a two-run lead in the bottom of the eighth when catcher A.J. Ellis scored on pinch-hitter Justin Turner's line-drive single to right field. Again, Arizona closed within one run and threatened to get more against right-handed closer Kenley Jansen.

Hill's single sent right fielder Gerardo Parra home and put first baseman Paul Goldschmidt at second with one out. But Jansen struck out Prado and got left fielder Cody Ross on a flyout for his 18th save.

Left-hander Clayton Kershaw (6-2) struck out seven batters and induced 10 groundouts in seven innings while allowing one run, eight hits and one walk.

The Dodgers took a 2-0 lead in the bottom of the second inning when left fielder Matt Kemp hit his sixth home run of the season, a two-run drive over the fence in left-center field off right-hander Chase Anderson. Later that inning, Los Angeles put runners in scoring position with two outs, but Anderson struck out second baseman Dee Gordon to end the threat.

In the top of the third, the Diamondbacks scored a run and put the potential tying run in scoring position. Shortstop Chris Owings hit a leadoff double and came home two outs later on Hill's double. Hill moved to third base on a wild pitch but stayed there when Prado struck out.

Owings made an unassisted double play in the bottom of the third. With one out and Dodgers shortstop Hanley Ramirez going from first base on a 1-1 pitch, Owings caught a line drive from first baseman Adrian Gonzalez, then tagged Ramirez to end the inning.

Anderson (5-1) was trying to become the first rookie since Jered Weaver in 2006 to win his first six decisions. The right-hander allowed two runs, seven hits, four walks and a hit batter in five innings while striking out four.

Spontaneous cheers and applause erupted in the bottom of the sixth when fans learned that the Los Angeles Kings won the Stanley Cup. Between the sixth and seventh innings, the video screen in left field showed the Kings scoring the winning goal in overtime and celebrating.

NOTES: Arizona 1B Paul Goldschmidt began Friday leading the National League with 83 hits, 27 doubles and 149 total bases. He also ranked second with 48 RBIs and 49 runs scored. ... The Diamondbacks recalled OF Tony Campana from Triple-A Reno after placing OF Ender Inciarte on the seven-day concussion list Friday. ... Arizona 3B Martin Prado needs four hits for 1,000 for his career and five RBIs from 400. ... The Dodgers activated C A.J. Ellis from the disabled list Friday and sent C Tim Federowicz to Triple-A Albuquerque. Ellis made Friday night's lineup. ... SS Hanley Ramirez returned to the starting lineup Friday night. An inflamed joint in his right shoulder limited Ramirez to a pinch-hitting appearance Wednesday night in Cincinnati and kept him out of Thursday's game. ... RHP Chad Billingsley has a partially torn flexor tendon in his right elbow, the Dodgers announced Friday. Surgery is one option being considered. ... The Dodgers signed 12 of the players they selected in last week's draft on Friday. Third-rounder RHP John Richy from UNLV was the highest pick to sign Friday.