Yankees pitcher Masahiro Tanaka reacts after his throwing error on...

Yankees pitcher Masahiro Tanaka reacts after his throwing error on a ball hit by the Rays' C.J. Cron allowed Matt Duffy to score during the first inning of a game Wednesday. Credit: AP / Chris O’Meara

ST. PETERSBURG, Fla. — It was not a persuasive closing argument by Masahiro Tanaka for getting the ball in next Wednesday’s AL wild-card game.

The righthander, coming off a rough start last Thursday against Boston, wasn’t particularly impressive Wednesday night against the Rays in his final regular-season start, an 8-7 loss in front of 11,325 at Tropicana Field.

“Obviously it’s disappointing,” Tanaka said through his translator. “The last two games probably would not give a good impression, but it’s not something I can take back.”

The Yankees (97-61) have a magic number of two to clinch home-field advantage for the wild-card game after Oakland defeated Seattle, 9-3, last Wednesday night.

“Valiant comeback there, just couldn’t finish it off,” said Aaron Boone, whose team trailed 8-3 going into the ninth.

Handed a 3-0 lead before throwing a pitch on Neil Walker’s three-run homer, Tanaka lost it in an ugly 36-pitch bottom half, an inning that included a key throwing error by the pitcher.

After Walker’s blast, the Yankees’ offense did nothing against the Rays until a stirring ninth against Sergio Romo.

Aaron Judge’s RBI single made it 8-4 and, with the bases loaded, Luke Voit’s two-run single to center — that just missed being a game-tying grand slam — made it 8-6, putting runners at the corners with one out. Judge, who was on first, had to hesitate at second as it appeared centerfielder Mallex Smith might have made a spectacular grab of the drive and was held at third.

Giancarlo Stanton’s infield single made it 8-7, bringing up Tyler Wade, who pinch ran for Walker in the eighth after he was hit by a pitch on his left shin (X-rays taken afterward were negative). Wade flied to right and Miguel Andujar fouled out to third, as the Rays exhaled.

“Longest single of my life,” Voit said. “I should have been on second. It was kind of a weird play because you couldn’t tell if he caught it or not. I kind of blame myself for that.”

Judge said he thought “off the bat” Voit’s ball was gone.

“When he connects, it goes a long way,” Judge said. “I thought it was hitting the flag out there.”

Tanaka, who had a 2.09 ERA in 10 second-half starts before last Thursday’s setback, has allowed a combined eight earned runs in his last two starts, though Aaron Boone said the righthander remains “in the mix” to start the wild-card game, along with Luis Severino and J.A. Happ, who seems to have emerged as the favorite.

“If we decide Masa’s going to be the guy,” Boone said, “I have tons of confidence he can go out and deliver.”

Wednesday night Tanaka departed after allowing a leadoff single in the fifth, trailing 4-3, having allowed four runs (three earned) and six hits. Tanaka (12-6, 3.75 ERA), who allowed Tommy Pham’s solo homer in the third that made it 4-3, walked one and struck out four.

David Robertson allowed four eighth-inning runs (three earned) that gave the Rays (88-70) an 8-3 lead.

One of the runs was unearned in the first as Tanaka, on a C.J. Cron comebacker, didn’t take the easy out at first and instead tried an off-balance throw to second. The throw sailed into center, the error allowing a run to score to make it 3-2.

“The common thread is the splitter,” Tanaka said of the main trouble his last two outings. “Being able to get some good bite on that pitch. After the Boston game I worked toward this game to make some adjustments and fix the issue, but it turned it out the way it did tonight. Hopefully I’ll work on it. I’m not sure where I’ll be pitching next, but I definitely need to get that pitch back.”

More Yankees headlines

Newsday LogoSUBSCRIBEUnlimited Digital AccessOnly 25¢for 5 months
ACT NOWSALE ENDS SOON | CANCEL ANYTIME