The tale of two Tanakas has been told countless times in his three-year career — a story so common, a result so reliable, that it really does seem as if two different pitchers take the mound, depending on the narrative.

It goes something like this: There is the Masahiro Tanaka on regular rest who gives up hits at an alarming rate, is a little wilder than usual and isn’t unaccustomed to seeing a slider or two end up in the bleachers.

Then there is the Tanaka of Sunday night — the righthander on extended rest who outpitched David Price at the Stadium, 3-1, and gave the Yankees some hope that maybe, just maybe, there’s something left to this season.

In a game that Joe Girardi called “probably the most important game that we’ve had in July in a long time,” Tanaka provided exactly what his teammates needed, giving up one run, three hits and a walk and striking out seven in six innings while pitching on six days’ rest.

When David Ortiz flied out to end the sixth, Tanaka left the field and tipped his hat, having done exactly what he is supposed to do: get the ball to Dellin Betances, Andrew Miller and Aroldis Chapman with a lead. Each pitched a hitless inning to close it out. “He gave us exactly what we needed,” Austin Romine said. “This is what we need — some timely hitting, getting a guy go six innings and then getting the big three.”

Though the Red Sox provided a scare here and there, Tanaka got his only big blunder out of the way early. With one out in the first, Dustin Pedroia deposited a 2-and-1 slider a few rows up in the leftfield stands.

advertisement | advertise on newsday

But with one out in the fourth, Didi Gregorius singled to center and Starlin Castro golfed a 1-and-2 changeup into the leftfield corner for a double that tied it at 1. Two-out RBI singles by Romine and Jacoby Ellsbury — sandwiched around a single by Brett Gardner — made it 3-1.

Price (9-7) lasted 5 2⁄3 innings, giving up those three runs and 11 hits and raising his ERA ever so slightly to 4.36. He left after giving up two-out singles by Gardner and Ellsbury and exited the diamond ingloriously to boos and the ‘90s *NSYNC hit “Bye, Bye, Bye.”

Meanwhile, Tanaka (7-2, 3.15 ERA) continued to prove a theory the Yankees have acknowledged but can’t do much to rectify. For reasons he can’t divine, he struggles on regular rest, and the numbers are striking.

In eight games on four days’ rest this year, he’s 1-2 with a 5.33 ERA and eight home runs allowed in 49 innings. Opponents have a .293 batting average and .470 slugging percentage.

In seven games on five days’ rest, he is 4-0 with a 1.05 ERA and one home run allowed in 51 1⁄3 innings. Opponents have a .193 batting average and .241 slugging percentage.

Yankees videos

In four games with at least six days’ rest, he is 2-0 with a 3.18 ERA and two homers allowed in 22 2⁄3 innings. Opponents have a .205 batting average and .361 slugging percentage.

“Possibly,” he said when asked if he feels differently on longer rest. “More rest means more time to sort of get the inflammation from the body, but the bottom line for me is just basically go out there and shut the opponent down regardless of the number of off days that you have in between starts.”

But even regular old four-day- rest Tanaka is better than most of the rest of the rotation, and the Yankees — embroiled in a brutal stretch that will determine whether they are buyers or sellers at the Aug. 1 trade deadline — can’t afford to sit him out and don’t currently have the personnel for a six-man rotation.

But for one night, it didn’t matter. The right Tanaka showed up, and because of it, the Yankees can dream of September relevancy for just a little longer.

“Every game we play from now on is important,” Gregorius said. “For us, today showed that we’re fighting and we’re not giving up.”