BOSTON — Didi Gregorius and Austin Romine each hit two-run homers off Chris Sale, and Domingo German struck out nine on Sunday night, helping the Yankees avoid a four-game sweep with a 9-6 victory over the Boston Red Sox.

Five days after allowing a career-high eight runs to the Minnesota Twins, German (13-2) took a no-hitter into the fourth and allowed four hits and a walk through five and a third innings. He has won four straight decisions and 10 of his last 11.

After trimming the Yankees’ lead in the American League East from 11 games to eight and winning the first three games of the series by a combined score of 38-13, the Red Sox committed three errors and fell into third place, nine games behind the Yankees in the division. The teams play four games in New York next weekend and four more at Fenway Park in September.

[The Yankees wanted Marcus Stroman. The Mets got him.]

The Red Sox had won five of six against the Yankees and Rays and moved briefly into playoff position, but with the loss Boston fell behind both Tampa Bay and Oakland for the A.L.’s second wild-card berth. The Rays visit Boston for three games, starting on Tuesday night.