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. He was pitching on six days’ rest, and 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.

Though the Red Sox’s loaded lineup 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. And for a while, that seemed as if it could have been enough to undo these offensively stunted Yankees.

But the Yankees eventually cracked Price. 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. The Yankees scored twice more in the inning on two-out RBI singles to center by Austin Romine and Jacoby Ellsbury sandwiched around a single by Brett Gardner.

Price 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 back-to-back 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 Tanaka can’t divine, he struggles on regular rest.

This year, he’s 1-2 with a 5.33 ERA in the eight games he’s pitched on four days’ rest, with a .470 opponents’ slugging percentage and eight home runs allowed. Entering Sunday night, on five days’ rest, he was 4-0 with a 1.05 ERA, a .241 opponents’ slugging percentage and one home run allowed.

On Sunday night, not having pitched since the previous Sunday, he again proved he can do wonders with extra downtime — a trend that more or less has manifested itself throughout his career.

But that’s the rub: 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.

Not with the Orioles coming to town, not with the Giants coming after that, and not with struggling Michael Pineda and Nathan Eovaldi representing two-fifths of the 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.