BOSTON — J.D. Martinez homered and drove in five, and the Boston Red Sox rallied from a five-run deficit to beat the Seattle Mariners 14-10 on Friday night despite a monster game from Nelson Cruz.

Cruz had a pair of three-run homers and drove in seven, but the Mariners still lost their season-worst fifth straight game, including three earlier this week at Yankee Stadium. Seattle led 4-0 and 10-5 before a wild Red Sox rally fueled by RBI from eight different players.

Martinez went 4 for 5, including a two-run homer in the sixth and two doubles. The Red Sox set a season high with 20 hits.

Reliever Matt Barnes (1-2) got the win with one scoreless inning, and Craig Kimbrel pitched the ninth.

Juan Nicasio (1-4) took the loss, allowing five runs on four hits in one-third of a lousy seventh inning.

The only flaw to the second half of the game for Boston: shortstop Xander Bogaerts left in the seventh with a sprained index finger on his left hand.

Ryon Healy hit a solo homer during Seattle’s four-run first inning as the Mariners got to knuckleballer Steven Wright. Seattle added two more off Wright in the second after Boston’s five-run bottom of the first.

Seattle scored four in the fourth, including Cruz’s second three-run shot of the game, but Boston’s bullpen shut down Seattle the rest of the way while the Mariners’ imploded.

Rafael Devers singled in a run in the fifth, and then Martinez homered off Nick Vincent to center in the sixth to pull Boston within 10-8. Mitch Moreland followed with a triple just beyond the reach of diving right fielder Mitch Haniger, and Bogaerts drove in Moreland with an infield single.

Barnes struck out the side in the seventh, and then Boston got to Nicasio. Devers singled to lead off, Blake Swihart singled with one out and Nicasio walked Mookie Betts to load the bases. Andrew Benintendi blooped a single into shallow center to bring in Devers and tie it at 10.

Swihart was nearly picked off third as Benintendi scored, but he slid under the tag after a strong throw by center fielder Guillermo Heredia. Seattle did not challenge the close play, and Martinez followed with a two-run single.

Nick Rumbelow later allowed Benintendi to score on a wild pitch, and Eduardo Nunez added a pinch-hit RBI single.