NEW YORK — Christian Yelich turned in quite an all-around performance that the Miami Marlins hope will help them turn the calendar on an awful August.

Yelich showed off his bat, legs and glove, capped by hitting a three-run homer as the Marlins beat shaky Jacob deGrom and the New York Mets 6-4 on Thursday night to end their season-worst five-game losing streak.

After going 10-18 in August, the Marlins pulled within three games of St. Louis for the second NL wild-card slot.

“It’s a new month, man,” Yelich said. “Hopefully September is better.”

Yelich homered for the third straight game, singled twice, drove in four runs and stole two bases. Plus, he made a dashing, diving catch in center field with the bases loaded and two outs — that made up for him later dropping a routine fly for an error.

The Mets lead Miami by one game in a crowded wild-card chase.

“Can we get hot? Who’s going to get hot?” Marlins manager Don Mattingly said. “Because one’s going to.”

Jose Urena (3-5) outpitched deGrom (7-8) as Miami averted a four-game sweep. Down 6-1, the Mets made it close, boosted by pinch-hitter Asdrubal Cabrera’s two-run homer in the ninth off Fernando Rodney.

DeGrom got seven days between starts because the Mets worried he was fatigued, but he still struggled. The shaggy-haired ace then waved for head trainer Ray Ramirez as he headed down the dugout tunnel toward the clubhouse when he was done.

“Everything’s fine,” deGrom said.

Mets manager Terry Collins said he hadn’t noticed deGrom signaling to the trainer, adding, “What you guys just informed me about is a little troubling to me.”

But Collins could tell something was off.

“It’s quite obvious when you walk four guys. He was behind in the count, he had a lot of pitches in five innings. That’s just not Jake. That’s the thing we’ve been watching is his command is not what it has been. That’s been the big issue,” he said.

DeGrom gave up three runs, six hits and four walks in five innings. He has lost three straight starts, tagged for a total of 16 runs, 31 hits and six walks in just 14 2/3 innings.

Urena allowed four hits, including Jay Bruce’s 29th homer, and one run in six innings.

Bruce hit an RBI single in the eighth and the Mets loaded the bases with no outs. But Michael Conforto grounded into a double play and pinch-hitter Yoenis Cespedes struck out.

It was scoreless in the second when the Mets loaded the bases with two outs. DeGrom hit a liner up the middle that Yelich, playing shallow for the pitch, rushed in to grab off the grass.

“He’s not afraid to play cheap,” Mattingly said.

Yelich hit his 18th homer in the seventh. He is hitting .410 (25 for 61) with four home runs and 13 RBIs in 16 games against the Mets this year.

The Marlins had scored only eight runs combined in their five straight losses. They have played 24 consecutive games decided by no more than three runs.

TRAINER’S ROOM

Marlins: All-Star OF Marcell Ozuna was out of the lineup, a day after hurting his left wrist trying to make a diving catch and leaving the game. He’s getting treatment and could play this weekend at Cleveland. … 1B Justin Bour (sprained right ankle) is set to face LHP Wei-Yin Chen (elbow sprain) in a simulated game Friday at the Marlins’ spring complex in Jupiter, Florida.

Mets: Cespedes and Cabrera didn’t start after it rained most of the afternoon. They have been banged up lately and “I don’t need them slipping on the turf,” Collins said. … Earlier in the day, 2B Neil Walker said he needed season-ending surgery for a herniated disk.

SEPTEMBER CALL-UP

OF Destin Hood was among the Marlins’ newcomers. He played high school football with A.J. McCarron and had committed to play wide receiver at Alabama, but was picked by the Washington Nationals in the second round of the 2008 draft and signed with them.

UP NEXT

Marlins: RHP Andrew Cashner (4-10, 4.73) is 0-3 in five starts since Miami got him in a trade with San Diego. He’ll pitch Friday night at AL Central-leading Cleveland against Carlos Carrasco (9-7, 3.23).

Mets: RHP Noah Syndergaard (12-7, 2.56) is 3-0 with a 1.31 ERA in his last three starts going into Friday night’s opener of a three-game series against NL East-leading Washington. A.J. Cole (0-1, 4.97) pitches for the Nationals.