NEW YORK — Twenty-two pitches in the afternoon, two pitches at night.

The two sides of Shohei Ohtani came as close together Sunday as they have been in his two seasons with the Dodgers. He pitched in a live batting practice session during the day, facing hitters for the first time in almost two years. A few hours later, he homered on the second pitch of the game, tying Aaron Judge and Kyle Schwarber for the major league lead with 18.

That was all the offense the Dodgers managed, however, in a 3-1 loss to the New York Mets on Sunday night.

After winning Friday night’s 13-inning, late-night affair, the Dodgers managed just three runs on 11 hits while losing back-to-back games at Citi Field. They hit into three double plays in each game.

The Dodgers have started their stretch of 29 consecutive games against teams with winning records by splitting six games and two series against the Arizona Diamondbacks at home and the Mets on the road.

“I really felt tonight we had a much better offensive approach — it didn’t show it — versus the other night, versus (David) Peterson,” Dodgers manager Dave Roberts said. “I think that the tale is we’ve just got to play clean baseball, have a good offensive approach, because we’re going to see some good pitching — we have. We’re going to, playing against some really good teams, so just our margin is much smaller.”

Their baseball was not clean Sunday. The Dodgers committed four errors — two by catcher Will Smith (one perhaps unfairly charged on a foul pop up into a strong wind), one each by Max Muncy and Mookie Betts.

But Ohtani’s daily double Sunday was impressive. He hit 97 mph with his fastball during the early workout on the mound, then clubbed a Kodai Senga fastball 108.2 mph 411 feet into the right-center field seats.

It was the fourth time this season Ohtani has led off a game with a home run. The Dodgers followed it up by putting runners at second and third with no outs after an error and a double by Freddie Freeman. But Betts tagged up on Will Smith’s fly ball to center field and was thrown out at the plate by Mets center fielder Tyrone Taylor.

“Tonight, you never want to feel that the first inning was the game. But you know, the double play, the Taylor play in center field, heck of a play,” Roberts said. “You have a chance to get three runs on the board versus one, they come back and hit a two-run homer in the bottom half.

“Tonight was one of those nights that we just gave them extra outs, and they took advantage. And we just couldn’t put much together versus Senga the rest of the way.”

Unlike Ohtani, Landon Knack did not get his day off to a good start.

Six of the first 11 Mets batters put balls in play with exit velocities of 98 mph or higher against Knack, including a two-run home run crushed by Pete Alonso in the first inning that put the Mets in the lead.

Alonso’s homer came after Muncy misplayed a ground ball with two outs, extending the inning.

“I let it hop up on me instead of going to get it,” Muncy said. “It’s a really frustrating one. It makes you feel like the game is on your shoulders. That’s how I feel, at least. It’s a play that needs to be made, and I should have made it. And it’s just a frustrating one.”

It was Muncy’s eighth error of the season. Only one third baseman has more (Manny Machado has nine).

“It’s tough. It’s one of those things where I’m just really not good defensively right now,” Muncy said. “Not going to shy away from it, but all I can do is keep showing up every day, working on it, trying to figure things out, trying to get better. That’s what I’ve been doing. That’s what I’m gonna keep doing. If you let it get you down, it’s gonna keep getting worse.”

In the third inning, more poor defense by the Dodgers figured into another run. With a runner on first and no outs, Betts fielded a ground ball up the middle and tried to flip it to Tommy Edman for a forceout at second base.

Betts’ flip was well over Edman’s head and onto the infield grass, allowing the runner to advance to third and score on the next play, a successful forceout at second base.

Knack transformed into a different pitcher after that. He retired 12 of the next 13 batters, completing six innings.

“I felt like the throw overall was good pretty much the whole time,” Knack said. “Felt like we had good command of pretty much everything we were trying to get in there. Fastball command was better today. Off speed was consistently over the plate. Just consistently on the attack more today.”

The Dodgers threatened against Senga again in the fourth inning when they put runners at the corners with two outs. But Andy Pages flew out to the warning track in left field.

They loaded the bases with two outs in the fifth, but Smith grounded out. The best-hitting team in the majors with runners in scoring position (a .306 average coming into the game), the Dodgers went 0 for 4 with RISP against Senga. They didn’t get another runner to second base until there were two outs in the ninth inning.

“We kind of keep shooting ourselves in the foot,” Muncy said of the offense the last two games against the Mets. “Feels like we have good at-bats, hit the ball hard, but then we’re just hitting it right at people, hitting into bad situations. And it’s been pretty frustrating. Just keep shooting ourselves in the foot.”