PHOENIX — David Freese homered and had three hits, leading Clayton Kershaw and the Los Angeles Dodgers past the Arizona Diamondbacks 7-4 on Monday night to maintain their lead in the NL West.

Manny Machado had two RBIs for the Dodgers, including a groundout deep into the shortstop hole with the bases loaded in the seventh inning that brought in Yasiel Puig with the go-ahead run. Los Angeles added three ninth-inning runs to stay 1 1/2 games ahead of Colorado, which routed Philadelphia 10-1 at Coors Field.

The defending NL champions have won six of seven.

MLB Standings: Playoff, Wild-Card Races Plus Matchups If Season Ended Today

Freese finished 3 for 4 with two RBIs and is batting .375 since joining the Dodgers at the beginning of the month. Kershaw (9-5) pitched six innings, allowing three runs and six hits in his fifth start against Arizona this season. He struck out six and walked one.

Ketel Marte homered and drove in three runs, all off Kershaw, and A.J. Pollock went deep against closer Kenley Jansen in the ninth. The Diamondbacks, already eliminated from playoff contention, have lost four straight and eight of nine.

With the Dodgers trailing 3-2 to start the seventh, Yasmani Grandal walked and Puig came through with a pinch-hit single off reliever Andrew Chafin (1-6). Brad Ziegler came on and gave up a pinch-hit single to Max Muncy that tied it 3-all.

With one out, Freese singled to load the bases before Machado knocked in the tiebreaking run. The Dodgers scored three runs in the ninth on two wild pitches by Yoshihisa Hirano and double by Machado that fell just short of a home run.

Diamondbacks starter Robbie Ray went five innings, allowing two runs and four hits with seven strikeouts and three walks.

Arizona tied it at 1 in the bottom of the first with Eduardo Escobar’s single and Marte’s triple, which eluded Matt Kemp’s lunging catch attempt in right field. Marte’s homer landed in the seats in left-center in the third for a 2-1 Arizona lead.

Freese ripped a 1-1 fastball from Ray opposite field over the right-field fence, tying it at 2 in the fifth. That brought chants of “Let’s go Dodgers!” from the many Los Angeles fans in the Chase Field stands.