NEW YORK — The path to the playoffs is about to get a lot tougher for the New York Yankees.

Dellin Betances threw a comebacker over the head of catcher Gary Sanchez, capping a troublesome, two-run ninth inning that sent the Los Angeles Dodgers over the Yankees 2-0 on a rainy Wednesday.

The Yankees have dropped three of four and are two games behind Toronto for the second AL wild card. The loss ended a 7-3 homestand.

Next up, they begin an 11-game trip — their longest of the season — to Boston, Tampa Bay and Toronto.

“It’s unfortunate. We had a really good homestand and this could have made it a great homestand and we weren’t able to get it done today,” manager Joe Girardi said. “We didn’t have a lot of chances. What it came down to was they got the late hit and we didn’t.”

Dodgers ace Clayton Kershaw pitched five nearly perfect innings and Justin Turner hit an RBI double off Betances to put Los Angeles ahead.

The Dodgers took advantage of errors by second baseman Starlin Castro and Betances to increase their NL West lead to five games over San Francisco.

Kershaw gave up one hit without a walk, pitching through two rain delays in his first career start at Yankee Stadium. The Yankees finished with three hits.

There was a brief, 12-minute wait in the middle of the fourth. After a 48-minute stoppage before the bottom of the fifth, Castro became the first Yankees batter to reach when Turner misplayed a hard grounder to third base for an error.

Chase Headley followed with a single, and a sacrifice put two runners in scoring position. Kershaw toughened, striking out Rob Refsnyder and Austin Romine to keep it scoreless.

Luis Avilan (2-0) got four outs and Kenley Jansen pitched the ninth, matching his career high with 44 saves in 50 chances.

Los Angeles took two of three in an interleague series between old October rivals.

It was scoreless when Betances (3-5) took over to begin the ninth. Corey Seager led off with a liner that got under Castro’s glove for an error, stole second and scored when Turner grounded a double down the third base line.

Turner moved to third on a flyball and scored as Betances fielded a tapper but threw it over the head of Sanchez.

“Every loss is a tough one now. Obviously we’re trying to make a push here for the playoffs, so it definitely hurts,” Betances said.

Yankees starter Michael Pineda pitched four innings, giving up two hits and two walks.

Pineda escaped his only jam in the fourth after a catcher’s interference call loaded the bases with one out. Andre Ethier grounded into a double play, with Pineda sprawled out at first base to catch the relay.

ROOKIE RUT

Batting ninth, Yankees newcomer Tyler Austin struck out all three times up. He has fanned in seven straight at-bats.

JUST VISITING

Nick Swisher hung around with his former Yankees teammates during batting practice. A popular slugger for the Yankees from 2009-12, he spent the first half of this season playing for their Triple-A team before stepping away. The 35-year-old Swisher was on MLB Network earlier this week. … Comedian Bill Murray was in the crowd.

TRAINER’S ROOM

Yankees: Rookie RF Aaron Judge is likely done for the regular season because of a Grade 2 strain of his right oblique, and has been put on the 15-day DL. He hurt himself taking a swing Tuesday night.

UP NEXT

New York begins a bruising trip when RHP Masahiro Tanaka (13-4, 3.04) starts at Fenway Park against Red Sox LHP Eduardo Rodriguez (2-7, 4.70) on Thursday night. The Yankees play four games in Boston, three at Tampa Bay and four in Toronto. It matches their longest trip in 10 seasons.