NEW YORK — Two big swings, both off the bench.

Left out of the starting lineup, Jacoby Ellsbury and Didi Gregorius hit back-to-back homers on consecutive pitches in the seventh inning to power the New York Yankees past the Los Angeles Dodgers 3-0 on Tuesday night.

Gary Sanchez added a leadoff home run in the eighth, CC Sabathia pitched three-hit ball for 6 1/3 innings and the Yankees helped their unexpected playoff push by winning for the eighth time in 10 games.

New York pulled even with Detroit, two games behind Toronto and Baltimore for the two AL wild cards.

"I think rest is helpful at this point in the season," Yankees manager Joe Girardi said. "We've seen a couple of times when we've given Jacoby a day off, he's been really good the next day and goes on a pretty good streak. So hopefully it happens when we give him a half day."

Prized rookie Julio Urias was lifted in the fourth by the Dodgers, who had won seven of nine before their latest offensive flop against left-handed pitching.

They have a four-game lead in the NL West over San Francisco, which lost to San Diego 6-4.

"As we finish out the next 18 games, we're going to see some left-handed pitching and rightfully so," manager Dave Roberts said after his team was blanked for the 10th time overall and second in three games. "So there's got to be some point where we break through."

In the series finale Wednesday afternoon, Dodgers ace Clayton Kershaw makes his first career start at Yankee Stadium.

Sabathia struck out seven and walked one as the Yankees rebounded from consecutive losses following a seven-game winning streak.

Adam Warren (3-1) retired both batters he faced, and Dellin Betances got four outs for his 11th save. The five-hitter was New York's 10th shutout of the season.

"This is lot of fun. This is what September baseball is about," Sabathia said.

Ellsbury originally was rested against the left-hander, but entered in the fifth when rookie right fielder Aaron Judge exited with an injury.

With one out in the seventh, Ellsbury drove a hanging breaking ball from right-hander Ross Stripling (4-7) into the second deck in right field to snap a scoreless tie.

"I knew at probably some point I'd come in the game," Ellsbury said. "I started getting ready about the third inning, so even with Judgie getting hurt in the fifth, I was ready to go."

Gregorius, nursing a sore rib, connected on Stripling's next pitch for his first career pinch-hit homer.

"It's good. I got treatment on it. If they needed me, I was ready," the shortstop said.

Sanchez went the opposite way against Jesse Chavez, the rookie's 14th home run in 136 at-bats this year.

Starlin Castro had three hits for New York.

The 20-year-old Urias, outdone by a fellow southpaw 16 years his senior, walked three and threw 78 pitches in what is expected to be his final start this season. Los Angeles plans to put Urias in the bullpen to limit his innings and get him ready for his potential post-season role.

"I'll be happy with whatever decision they take," Urias said through a translator.

BIG SWINGERS

The last time two Yankees hit consecutive homers in a game neither started, it was Moose Skowron and Tommy Byrne who connected in July 1957 at the Chicago White Sox, the Elias Sports Bureau said.

TRAINER'S ROOM

Dodgers: LHP Brett Anderson, on the disabled list with a blister on his index finger, is scheduled to make a rehab start Friday for Triple-A Oklahoma City in Game 3 of the Pacific Coast League championship series against El Paso.

Yankees: Judge was removed with a right oblique strain and will have an MRI on Wednesday. "We won't see him for a while," Girardi said, acknowledging it's possible Judge could miss the rest of the season. Judge was batting in the fourth when he was checked by Girardi and a trainer, but initially stayed in and drew a walk. He said he got hurt on one particular swing. "Just wanted to try to finish out the at-bat," he said. "It's tough. No one wants to go through it, especially right now." ... Girardi said he thinks Gregorius feels better and will be able to start Wednesday.

UP NEXT

Dodgers: Kershaw (11-3, 1.89 ERA) is set to make his second start since missing more than two months with a back injury. The ace left-hander threw 66 pitches over three innings last Friday in a 4-1 loss at Miami, but Roberts wouldn't say how many Kershaw might throw this time. "It'll be more than his last start," Roberts said. "We expect Clayton to be Clayton."

Kershaw has faced the Yankees twice at Dodger Stadium, allowing two earned runs over 15 innings (1.20 ERA) in a pair of no-decisions — the last in July 2013.

Yankees: RHP Michael Pineda (6-11, 5.07) is 0-1 with a 4.65 ERA in his past six starts.