LOS ANGELES — Didi Gregorius hit a grand slam off the All-Star Hyun-Jin Ryu and added a solo shot to help the Yankees set a club record for homers in a month as they routed the Los Angeles Dodgers, 10-2, Friday night in a matchup of the two teams with the best records in baseball.

Aaron Judge, Gary Sánchez and Gleyber Torres also homered as the Yankees ended a four-game skid. They have a major league-leading 57 homers in August, their most in any month.

Starting on five days’ rest, James Paxton (10-6) allowed two runs and five hits in 6 2/3 innings to win his fifth straight start. He struck out 11 — one off his season high — and walked none.

The teams’ first meeting in three years had a postseason feel, even though neither club looked the part. The Yankees’ pinstripes and Dodgers’ blue and white uniforms were cast aside on Players’ Weekend. The Yankees wore all black and the Dodgers donned all white with player-chosen nicknames on the back.