Mark Teixeira knows how to hit a home run. That comes with skill and accumulated knowledge from years of sizing up pitchers and their patterns and their stuff.

It’s just that most days now, Teixeira cannot hit a homer. His mind is fertile. His body is decaying.

Even he concedes: “My bat is a little slow right now and that is no secret. Teams know that.”

But Friday night he said, “my bat was quick.” It was one of those rare times these days when his 36-year-old body felt in synchronicity with his baseball brain. Maybe it was having started just one of the previous four games. Perhaps it was the rejuvenation offered by the 90-plus minutes of acupuncture and lasers and heat pads and hot rub applied particularly to his neck and right knee.

Whatever it was, Mark Teixeira played young. He came to the plate five times and reached all five. Most vitally, he was the batter with two outs and three on in the bottom of the fourth. In the previous half inning, the mercurial Michael Pineda had served up homers on consecutive pitches to allow Tampa Bay to crawl within 3-2.

So here was a chance to regain control of a game, something Teixeira had helped do plenty throughout his starry career, but was finding harder and harder these days to the point you could wonder if his finish line would come before another huge moment.

But Teixeira had nine previous at-bats against reliever Kevin Jepsen, the most on the current Yankees, and that included one homer. And when the righty threw a fastball away followed by a change-up in and down in the dirt, Teixeira’s computer made a decision.

“I was trying to hit a homer,” he said.

The sequencing suggested to a wise, observant veteran that another fastball away was next and Teixeira decided if the pitch was out over the plate, he would put the best swing he had left — get the bat head out and try to pull with fury.

“You have to know how to hit a homer,” Teixeira said. He hit No. 406 of his career into the Yankees’ bullpen, his 11th grand slam. It was the key blow in a 7-5 triumph that pulled the Yankees within a game of the second wild card, currently occupied by Detroit and Baltimore.

This all would have seemed impossible, say, on Aug. 6, roughly a week after the Yankees had traded three of their best players plus Ivan Nova, and the day on which Teixeira announced he was retiring. This was a decaying veteran saying goodbye for a team that had just sold. The next step was irrelevant at-bats in September.

Instead, on Sept. 9, Teixeira was summoned for a curtain call amid a steadily believing crowd that was watching the Yankees win their sixth straight and climb to 10 over for the first time this year.

At this moment, Teixeira cannot know if something is the last one. Heck, it is just hard enough for him to get on the field. Joe Girardi usually tries to find the right matchups in which to start Teixeira and he liked the switch-hitter’s patience against the command issues of Rays rookie starter Blake Snell enough to put Teixiera at first, bat him fifth.

“That feeling I had tonight,” Teixera said. “I haven’t had it a lot this year.”

That is why Tyler Austin is playing first more these days. Austin is part of a youth brigade, and he hit a walk-off homer Thursday night. But what the kids don’t have is the years of accumulated wisdom.

Sometimes that no longer matters. Alex Rodriguez was a baseball savant, but his quick-twitch skills were just too far gone. Girardi said he has seen enough on occasion from Teixeira to suggest they are there, not to be used daily, but still to be useful.

“I am emptying the tank,” Teixeira said. “Whatever I have left, I will put on the field.”

He did that Friday. He felt young and his swing felt quick and his experienced baseball brain made that worthwhile. The finish line is coming for Teixeira amid the Yankees’ youth movement. For one more night anyway, he was young.