ST. PETERSBURG, Fla. — Masahiro Tanaka has said he’s happy to take the ball every fifth day, but there are benefits to taking it every sixth.

“Sometimes you feel a little bit more rested,” he said last week. “But I’m always preparing myself to go on the fifth day. That’s really not a problem for me.”

Still, the numbers are becoming overwhelming. The righthander, pitching with five days’ rest for a second straight outing, again was terrific as the Yankees beat the Rays, 4-1, Friday night at Tropicana Field.

Tanaka, coming off a start against the A’s in which he allowed one run and five hits in seven innings, was perfect through four innings and allowed two hits and no walks in seven shutout innings. “That’s the formula for us,’’ Alex Rodriguez said. “If you look at what Tanaka did today, it’s unbelievable. He was so efficient with his pitches. it looked like he could have pitched a complete game.”

He was backed offensively by Rodriguez’s sixth homer of the season, a two-run shot in the sixth inning, and Carlos Beltran’s 11th homer, a solo blast in the eighth, as the Yankees (23-24) took a 4-0 lead. Steve Pearce’s two-out homer off Kirby Yates in the ninth spoiled the shutout.

In the last nine games, Yankees starting pitchers have a 1.72 ERA and a 0.73 WHIP in 57 2⁄3 innings. The have gone at least six innings in each game and have allowed two or fewer hits four times in that span.

Tanaka (3-0, 2.89) was so good that Joe Girardi let him pitch the seventh with a 3-0 lead, giving Dellin Betances a break.

Said Brian McCann, “He kept them off balance from pitch one. Got quick outs. We looked up there in the sixth and he’s got 55 or 60 pitches . . . When you do that, you’re doing something right.”

After Pearce’s homer in the ninth, Girardi went to Aroldis Chapman. He struck out Logan Morrison, who reached base when McCann failed to hold on to the third strike, and struck out Desmond Jennings to end it.

Rays righty Chris Archer matched Tanaka zero for zero until the sixth. Brett Gardner walked with one out and went to third when Archer threw away a pickoff attempt, with the ball rolling down the rightfield line. Second baseman Taylor Motter then booted Beltran’s grounder for an error, putting runners at the corners for McCann. He sent a ground smash off the glove of first baseman Morrison that turned into a forceout at second but made it 1-0. A-Rod then pounded a belt-high 95-mph fastball to left-center for a two-run shot that made it 3-0.

Archer (3-6, 4.62), who entered the game with a 5-2 record, 2.25 ERA and 0.93 WHIP against the Yankees, allowed four runs, four hits and three walks in eight innings, striking out seven. Two of the hits came in Jacoby Ellsbury’s first two at-bats, making him 18-for-26 with four walks at that point against Archer.

The Rays (21-25) had few hard-hit balls until Pearce led off the fifth with a single. He moved up on a wild pitch but committed a gaffe by taking off when Morrison grounded back to Tanaka. He aggressively ran at Pearce and tagged him for the out, got Jennings to ground into a forceout and pounded his glove in celebration when Gardner chased down Corey Dickerson’s drive to the wall in left-center.

Tanaka, through his translator, said he was “maybe not as sharp as it looked.” He added, “They got some good hits, but I think our defense did a spectacular job, and that helped me out . . . Obviously, Gardner helped me out in a big way.”