Trailing 4-2 at London Stadium, New York sent 14 men to the plate in their highest-scoring inning of the season. First baseman DJ LeMahieu extended his hitting streak to 14 games with a leadoff double and scored on center fielder Aaron Hicks' double.
All-Star catcher Gary Sanchez singled right fielder Aaron Judge and Hicks home. Third baseman Gio Urshela added a two-run single and LeMahieu, who will start next month's All-Star Game at second base, brought two runners home with another double.
Yankees shortstop Didi Gregorius' eighth-inning home run gave the Yankees a Major League-record 31 straight games with a home run.
Boston wasted a 4-0 first inning lead and 5 1/3 innings of two-run ball by veteran Eduardo Rodriguez. The Red Sox hit three home runs in the first inning for the first time since August 1979.
Boston rallied for four runs in the eighth against relievers Chance Adams and Zack Britton, but couldn't tie the game. The Red Sox are only 44-40 this season after winning the World Series last year.
Yankees closer Aroldis Chapman shut the door in the ninth inning.
New York is 54-28 this season. The first-place Yankees have a seven-game lead over the Tampa Bay Rays.