Aaron Judge and Jazz Chisholm Jr. hit back-to-back home runs in the first inning, Alex Verdugo's RBI single chased Jack Flaherty in the second and Giancarlo Stanton's third-inning homer against Ryan Brasier built a 5-0 Yankees lead.
But errors by Judge in center and Anthony Volpe at shortstop, combined with pitcher Gerrit Cole failing to cover first on Betts' grounder, helped Los Angeles score five unearned runs in the fifth.
After Stanton's sixth-inning sacrifice fly put the Yankees back ahead 6-5, the Dodgers loaded the bases against closer Tommy Kahnle in the eighth before the sacrifice flies off Luke Weaver.
Winner Blake Treinen escaped a two-on, one-out jam in the bottom half by retiring Stanton on a flyout and striking out Anthony Rizzo.
Walker Buehler, making his first relief appearance since his rookie season in 2018, pitched a perfect ninth for the save.