The Yankees understand there is more to a tight September race than the youth-driven joy ride they have been on. Players get tired and banged up. They need rest the most when they least want to take it. The fortunate part is that sometimes, all it takes is one night off, or maybe four innings.

Jacoby Ellsbury entered in the fifth inning of a vitally important game, after Aaron Judge strained his right oblique on an awkward swing, and broke a scoreless tie with a home run to rightfield in the seventh. Then Didi Gregorius, kept out of the starting lineup for a second consecutive game because of sore ribs, came up next as a pinch hitter and also homered to right. Those veterans built on the excellent work of another, starter CC Sabathia, and helped the Yankees beat the Dodgers, 3-0, in a game they really could not afford to lose.

They had dropped two in a row and their margin for error was squeezed to just about nothing. So it was just the sort of time that a guy does not want to sit.

“A little four-inning breather? Obviously, you want to play every single day, but with that, sometimes a few innings off will make you better for the rest of the way,” Ellsbury said, after he hit the first of two successive homers against reliever Ross Stripling. “Ultimately, as a competitor you never want to come out of the lineup, but you realize that sometimes it’s to the benefit of the team, and you, to maybe have a few innings off.”

Ellsbury said he had started getting loose in the third inning of a game that was October tight. As it is, the Yankees are two games behind the Orioles and Blue Jays for the second wild card, and tied with the Tigers. The Yankees don’t want to think about how they would have felt had they lost again Tuesday night against the top team in the National League West.

So there is heat on everyone. Joe Girardi was not taking any chances, going to Dellin Betances for a four-out save, preserving the victory for Adam Warren (3-1). They got breathing room in the eighth when Gary Sanchez hit the 14th home run of his remarkable rookie season.

advertisement | advertise on newsday

None of that would have been possible without Sabathia, who left to a standing ovation with one out in the seventh. The Yankees needed plenty from him and could not have asked for more.

“We need to win pretty much every game. That just comes with the territory of being in a playoff race. No extra pressure, I just go out and do my job,” Sabathia said after he allowed only three hits and one walk and struck out seven. “This is 16 seasons for me, so it’s just natural now to go out and worry about what you need to focus on and try to get us a win.”

Gregorius is having a career year, which includes 18 home runs. He never wants a day off, but he has been so sore that Girardi kept him out of the starting lineup two nights in a row. The shortstop understands, but he also knows he must be ready. “If you’re tired, you’re tired,’’ he said. “You’ve got to go out and play the game.”

So how does that rib cage feel?

“The same,” he said, smiling. “I mean, it wouldn’t be different because I hit a home run.”

Yankees videos

Girardi noticed lately that Ellsbury just needed a break. “We’ve seen a couple times, we gave Jacoby a day off and he’s been really good the next day and goes on a pretty good streak,” the manager said. “Hopefully, it happens when you give him half a day.”