ST. PETERSBURG — Harrison Bader stayed prepared on his off day for a important moment.

Bader flared a two-run single during a three-run eighth inning, and the New York Yankees rallied from a two-run deficit to beat the major league-leading Tampa Bay Rays 3-2 on Saturday.

“He’s a lot of fun to be around.” Yankees manager Aaron Boone said. “He loves to play the game. He loves to compete. Today he’s off, and he’s ready to go the whole game knowing that that situation might be coming up.”

Tampa Bay had been 22-0 when scoring first, matching the 1884 St. Louis Maroons of the Union Association for the longest winning streak opening a season when scoring first, according to the Elias Sports Bureau. The Rays are 18-3 at Tropicana Field.

A day after hitting a three-run homer, Bader singled as a pinch hitter in the seventh and put the Yankees ahead 3-2 on his 179-foot, 64.2 mph hit off Kevin Kelly (3-1).

“I was kidding him, I said ’you couldn’t have lobbed them out there better than that,” Boone said.

Anthony Rizzo singled against Jalen Beeks, Gleyber Torres singled against Kelly and DJ LeMahieu, after falling behind 0-2 in the count, sliced a slider down the right-field line for an opposite-field RBI double.

Willie Calhoun popped out and Bader, who made his season debut Tuesday after recovering from an oblique injury, looped a hit into short right field.

Ron Marninaccio (1-1) went 1 1/3 scoreless innings to get the win before Ian Hamilton worked around Luke Raley’s two-out double in the ninth for his first major league save, retiring Isaac Paredes on a game-ending flyout.

Tampa Bay went 1 for 12 with runners in scoring position.

“That big hit just didn’t come easy today,” manager Kevin Cash said.

New York (18-16) moved back within nine games of the Rays (27-7) in the AL East with its first victory this season (1-14) when trailing after seven innings. Tampa Bay had been 23-0 when ahead after seven.

The Yankees are without sluggers Aaron Judge (strained right hip), Giancarlo Stanton (left hamstring strain) and Josh Donaldson (strained right hamstring).

The announced crowd was season-high 27,078 at Tropicana Field as the Rays opened up the normally closed upper deck for the weekend series.

Tampa Bay took a 2-0 lead on Manuel Margot’s two-run double off Domingo Germán in the first, a 107.9 mph shot that went between the legs of LeMahieu at third base.

Tampa Bay starter Drew Rasmussen scattered two hits in 5 2/3 scoreless innings.

Beeks worked out of a second and third one-out jam in the seventh by striking out Aaron Hicks and Kyle Higashioka. Hicks, booed by Yankees fans in attendance, went 0 for 4. He is batting .135 (7 for 52) with no extra-base hits, one RBI and 15 strikeouts.

NEW POSITION

Isiah Kiner-Falefa started in center field for the Yankees but made his first professional appearance in right after Bader hit for Jake Bauers. IKF has played every position in the majors except first base. His double in the eighth was first extra-base hit this season.

CLUBHOUSE RACKET

The Yankees clubhouse was extra boisterous postgame, but there was more to it than the win.

“I think it’s probably more Kentucky Derby,” Boone said with a smile.

TRAINER’S ROOM

Yankees: Boone expects Judge to return from a strained right hip on Tuesday.

Rays: LF Randy Arozarena was the DH, one day after his knee made contact with Yankees 2B Gleyber Torres on a slide into second and went 1 for 4. ... 2B Brandon Lowe started after missing two games with back soreness and was hitless in four at-bats. He was limited to 65 games last season due to back issues.

UP NEXT

Yankees: RHP Gerrit Cole (5-0) will start Sunday’s series finale. He went 1-1 with a 1.07 ERA in four outings against Tampa Bay last season.

Rays: LHP Josh Fleming (0-0) will start or follow an opener. He had a successful bullpen session Friday after taking an 113.1 mph infield single off his left foot Tuesday.