BOSTON — In the long-storied history of the Yankees-Red Sox rivalry, this was among the longer ones — nearly six hours, more than 500 pitches.

That is, if it’s officially over.

Didi Gregorius lined a go-ahead single in the 16th inning and New York wound up winning 4-1 Saturday in a game Boston played under protest after a bizarre sequence on the bases. Not since 1966 had the Yankees and Red Sox gone so deep at Fenway Park.

Matt Holliday hit a tying home run off Boston closer Craig Kimbrel in the ninth that cleared the Green Monster, and it took 5 hours, 50 minutes and 512 pitches to finish.

Both teams burned through their bullpens, and the relievers won’t get much rest — the Yankees and the AL East-leading Red Sox were set for a day-night doubleheader Sunday.

“It’s a good feeling,” Yankees manager Joe Girardi said. “That’s a long grueling game and Matt Holliday hits a huge home run in the ninth inning to tie it up that led to however many innings we played.”

Holliday drew a leadoff walk in the 11th and Jacoby Ellsbury followed with a grounder to first baseman Mitch Moreland, who threw to second for a forceout. Holliday, however, retreated toward first and slid into the bag as shortstop Xander Bogaerts’ throw arrived.

Moreland wasn’t able to reach the ball, which hit Ellsbury and bounced into foul territory. Boston manager John Farrell argued in favour of an interference call and after a lengthy review, the umpires allowed Ellsbury to stay on first.

“A lot of opportunities, a lot of missed opportunities, a lot of very good pitching over the majority of today,” Farrell said. “Chris Sale was outstanding once again. A rare non-converted save by Craig today and then some opportunities following that. A base hit with men in scoring position just wasn’t there today.”

Yankees starter Luis Severino allowed one run and four hits in seven innings. He gave up Moreland’s sacrifice fly in the third.

“When you get somebody like Sale pitching, you have to get going to try your best,” Severino said.

Ben Heller (1-0) went two innings. Seven Yankees relievers combined to blank Boston on four hits for nine innings.

Doug Fister (0-3) gave up three runs in the 16th. Ellsbury led off with a double, Gregorius and Austin Romine hit RBI singles and Gary Sanchez added a sacrifice fly.

A day after Yankees blew a ninth-inning lead and lost, they rallied to win for just the eighth time in 28 games. New York closed within 3 1/2 games of Boston.

The Red Sox had been 43-0 when leading after eight. Kimbrel, the winning pitcher in the All-Star Game on Tuesday night, had his first career blown save at Fenway following 30 successful ones.

The clubs last played 16 innings at Fenway on June 4, 1966, when Jim Gosger’s three-run homer gave Boston a 6-3 victory. In 2015, Boston beat New York 6-5 in 19 innings at Yankee Stadium.

“Sometimes one pitch can be the outcome of the entire game,” Kimbrel said. “It seemed like that was kind of it today.”

TRAINER’S ROOM

Yankees: Girardi said the club was “hopeful” that OF Aaron Hicks, on the 10-day disabled list with a strained right oblique, would “start doing some light baseball activity” when the club returns from its season-long, 11-game trip.

Red Sox: Placed RHP Joe Kelly on the 10-day DL before the game with a strained left hamstring and recalled RHP Brandon Workman from Triple-A. … RHP Blaine Boyer left with right elbow tightness. … Bogaerts put on a soft brace to support his left ring and pinkie finger under his batting glove halfway through batting practice.

Honoured

The Red Sox welcomed about 1,300 Vietnam veterans and their families onto the field during a pregame ceremony.

UP NEXT

Yankees: LHP CC Sabathia (7-3, 3.81 ERA) is set for the opener and RHP Masahiro Tanaka (7-8, 5.47) in the nightcap Sunday.