Didi Gregorius ripped a go-ahead run-scoring single as the New York Yankees scored three runs in the 16th inning to beat the Red Sox 4-1 in Boston on Saturday night.
The American League East rivals battled five hours and 50 minutes at Fenway Park before the Yankees came away with a much-needed win.
Jacoby Ellsbury, who entered the game as a pinch runner in the ninth inning, doubled off Red Sox relief pitcher Doug Fister to lead off the Yankees' 16th.
Chase Headley's bloop single to center field put runners on first and third to set up Gregorius' single to center.
Austin Romine singled in another run and Gary Sanchez added a sacrifice fly after a Ronald Torreyes sacrifice bunt and Fister's intentional walk to Brett Gardner.
New York were looking at their 20th defeat in 27 games when Matt Holliday belted a game-tying solo home run in the ninth, his 16 of the season.
With the win the Yankees pulled within 3 1/2 games of division leaders Boston.
Yankees starter Luis Severino allowed just one run, four hits and two walks with six strikeouts in seven innings.
Reliever Ben Heller struck out three and pitched the final two innings for the victory.
Boston starter Chris Sale, the American League starter in the All-Star Game last Tuesday, matched a season high with 13 strikeouts in 7 2/3 scoreless innings.
Southpaw Sale became the first Red Sox hurler since Pedro Martinez in 2003 with multiple 10-plus strikeout games against the Yankees in a season.
He gave up three hits and two walks before being relieved by Craig Kimbrel, who proceeded to blow a save at Fenway for the first time.
Mitch Moreland drove in the lone run for Boston.
Sale was greeted with an ovation when he came back out to start the eighth, but the cheers turned to boos when Red Sox manager John Farrell pulled him with two outs, a runner on first and the Yankees' rookie slugger Aaron Judge coming to the plate.
After a 10-pitch at-bat, Kimbrel coaxed Judge into an inning-ending fly out to right field.
But Holliday took Kimbrel deep to lead off the ninth, sending a 1-1 pitch over the Green Monster left field wall.
Things turned strange in the 11th, when Ellsbury sent a ground ball to first with Holliday on first.
Moreland fielded the ball on a bounce and fired to second for the first out, but Holliday turned around and slid back into first just as Ellsbury arrived at the base.
Shortstop Xander Bogaerts' throw to first was blocked by Holliday, leading to an umpires' review for a rules check.
The original call that Ellsbury was safe was upheld after a review lasting almost five minutes.
Farrell, who wanted Holliday called for interference, told the umpires that Boston would play the rest of the game under protest.