LOS ANGELES — One strike away from forcing extra innings on Tuesday, Mets reliever Hansel Robles tried his hand at gamesmanship. The hard-throwing righthander picked the wrong time to get cute.

Pinch hitter Trayce Thompson’s two-out solo shot in the bottom of the ninth lifted the Dodgers to a 3-2 victory, ending the Mets’ three-game winning streak. It came after Robles shook off catcher Kevin Plawecki, who had signaled for a slider. Through a translator, Robles said he shook off the sign hoping to “confuse” Thompson.

“But,” Robles said, “he confused me.”

Robles had entered the game with a 1.35 ERA in 13 1⁄3 innings, part of a bullpen that has flourished in the season’s opening month. He ended it by giving up his first home run of the season, the final twist on a night in which the Mets could find only slivers of good news.

“He left it up in the zone,” Mets manger Terry Collins said of Robles’ fastball “There’s not much else to say.”

Indeed, the Mets endured a strange night, tinged with contradictions.

advertisement | advertise on newsday

Jacob deGrom allowed two runs and tossed a season-high seven innings, but he did so by battling the same mechanical demons he did in his previous start.

Yoenis Cespedes made a pair of sparkling defensive plays, but rolled his ankle while getting back to first base on a pickoff attempt. Both Cespedes and Collins insisted that the ankle was fine.

David Wright made a run-saving, diving stop. But twice, his diminished arm strength at third base came into focus. Collins acknowledged that Wright’s sidearm throws this season are just the latest concession to a back made vulnerable by the condition spinal stenosis.

Mets videos

Still, on a night when plenty went wrong for the Mets (20-12), they found themselves with a chance to win.

Thompson’s game-winning homer came one inning after lefty reliever Antonio Bastardo extricated the Mets out of a tight jam in the eighth inning, surviving a leadoff ground-rule double by Corey Seager.

And before that, deGrom again showed a measure of mental toughness, departing with the game still tied at 2-2.

Said Collins: “This night shows what Jake deGrom’s made of.”

Just as he did in his previous start, deGrom acknowledged that he didn’t feel comfortable. He knew early this would be a slog. He described his pitches as “flat, in the zone,” the natural fallout from faulty mechanics. The pitcher resorted to adjustments on the fly.

advertisement | advertise on newsday

Said deGrom: “It’s a mental battle.”

The last time deGrom took the mound at Dodger Stadium, he endured the most mentally draining start of his career, walking through a six-inning minefield to rescue the Mets in a classic Game 5 of the NLDS. With one start, on the biggest stage he had graced to that point in his career, deGrom showcased his mettle.

Of course, the stakes Tuesday night were nowhere close to the ones that deGrom faced on that tense October night. But the outline of his outing looked vaguely familiar, with deGrom settling down after allowing a pair of early runs.

Until Tuesday night, deGrom had handled lefties, who were just 10-for-49 (.204) against him. They had combined for just one extra-base hit. Nevertheless, Dodgers skipper Dave Roberts started six lefties against deGrom, which proved to be the right move.

Chase Utley and Seager, both lefties, opened the game with consecutive doubles to give the Dodgers a 1-0 lead. Two batters later, Adrian Gonzalez lifted a sacrifice fly. Lefties collected six of eight hits against deGrom, including four for extra bases.

advertisement | advertise on newsday

“When you throw balls down the middle, you see some pretty good swings,” deGrom said. “I think that contributed to that.”

But deGrom buckled down from there, working out of a jam in the third before getting help from his defense the rest of the way.

Wright knocked down a scorching grounder, saving what could have been a run. But in the eighth, his lack of arm strength cost the Mets a chance at what would have been a critical double play.

Shortstop Asdrubal Cabrera made a barehanded pickup on a ball slowed down by deGrom’s deflection.

Cespedes took away a Yasiel Puig hit with a leaping grab up against the wall. Later, Cespedes fired a strike from the warning track in centerfield to throw out Gonzalez at second base, just after he struck the fence with a near home run.

According to Statcast, Cespedes’ 232-foot throw was clocked at 91.1 mph.

The Mets mustered little against Alex Wood, who struck out nine in 6 1⁄3 innings. The Dodgers lefty allowed a pair of runs in the second, though the blame fell squarely on second baseman Utley.

It was Utley’s errant throw that allowed Cespedes to score from second base. One batter later, Plawecki stroked a game-tying RBI single.

The Mets’ next threat to score didn’t come until the eighth, when Dodgers reliever Pedro Baez allowed a one-out single to Juan Lagares and then plunked Cabrera on the elbow. But Wright couldn’t catch up to a 98-mph heater and Cespedes bounced into a forceout.