ST. PETERSBURG, Fla. — Ji-Man Choi hit a game-ending home run in the 12th inning, giving Tampa Bay a 2-1 victory against the Yankees on Tuesday night. The Rays remained on track for an American League wild-card berth on a night C. C. Sabathia pitched a perfect inning for the Yankees in his first career regular-season relief appearance.

Choi homered off Cory Gearrin (1-3), the last of 11 Yankees pitchers, after Pete Fairbanks (2-3) struck out Brett Gardner with a runner on second and two outs in the top half.

Tampa Bay remained a half-game ahead of Cleveland for the second A.L. wild card.

The Yankees (102-56) slipped as they tried to overtake Houston (102-54 entering Tuesday’s game at Seattle) for best record in the A.L. and home-field advantage throughout the league playoffs.

Sabathia, a 39-year-old left-hander who is retiring at the end of the season, had made 560 regular-season starts but is being moved to the bullpen along with J. A. Happ ahead of the postseason.