NEW YORK — For Clayton Kershaw and the Los Angeles Dodgers, pitching five innings was nearly perfect.

They almost were, too.

Kershaw gave up just one hit in a start twice interrupted by rain, and Justin Turner grounded an RBI double off Dellin Betances in a two-run ninth that sent the Dodgers over the New York Yankees 2-0 Wednesday.

“For us to see Clayton go out and do what he does, it’s a huge lift for us,” manager Dave Roberts said.

The lefty ace threw 64 pitches in his second start since missing 10 weeks because of a herniated disk in his lower back. Last week in his return, he gave up two runs and five hits in three innings at Miami.

“Overall, a little bit better, for sure,” Kershaw said.

Of course, the three-time Cy Young Award winner still saw room for improvement.

“I gave up a hit,” he said, “so there’s a bad pitch there.”

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.

The Yankees completed a successful homestand and remained two games behind Toronto for the second AL wild card. Next up, they begin an 11-game trip — their longest of the season — to Boston, Tampa Bay and Toronto.

“I don’t think you can forget the positive homestand that we had. We were 7-3 against some pretty good teams,” manager Joe Girardi said. “Obviously, this is a big road trip and we understand that.”

Kershaw walked none in his first career start at Yankee Stadium and exited with a 1.81 ERA. He struck out three and has fanned 153 while walking just nine this season.

“It’s a good springboard,” he said.

There was a brief, 12-minute wait in the middle of the fourth. Kershaw kept loose by throwing underneath the stands during 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.

Kershaw gave a quick fist pump after the escape.

“It was good to see that emotion,” Roberts said.

Castro previously played for the Cubs, and faced Kershaw in the National League. Castro said Kershaw looked as good as ever.

“Yeah, I can tell that. His velocity is up there. All his breaking balls are up there. I think he’s the same guy,” Castro said.

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

Los Angeles threw its major league-leading 15th shutout and won 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 comebacker by Yasmani Grandal but threw it over the head of catcher Gary Sanchez.

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

INTERLEAGUE INTEL

The Dodgers went 10-10 in interleague play this season, including a 5-3 mark at AL East parks. Los Angeles is 7-6 against the Yankees in regular-season play — Philadelphia, at 14-13, is the only other team in the majors with a winning record vs. the Yankees in the regular season. … The Yankees went 8-12 against NL teams this season.

TRAINER’S ROOM

Yankees: Rookie RF Aaron Judge is likely done for the regular season because of a strained right oblique, general manager Brian Cashman said. Judge hurt himself taking a swing Tuesday night, and has been put on the 15-day disabled list.

UP NEXT

Dodgers: LHP Rich Hill (12-3, 1.80 ERA) starts at Arizona vs. RHP Archie Bradley (6-9, 5.10) as LA continues a 10-game trip. Hill has won nine straight decisions, and was pulled with a perfect game in progress after seven innings at Miami in his last start because of concerns about a recurring blister.

Yankees: 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.