MIAMI (AP) — Javier Báez hit a tiebreaking homer in the eighth inning after scoring on a nifty slide in the second, and the New York Mets snapped a three-game losing streak with a 5-3 victory over the Miami Marlins on Wednesday night.

The Mets, who had lost five of six, let an early 3-0 lead slip away but recovered to maintain their 1 1/2-game lead in the NL East over surging Philadelphia.

Báez, acquired in a trade-deadline deal with the Chicago Cubs last Friday, put New York back in front 4-3 with an opposite-field drive off Anthony Bass (1-7) that sailed into the front row of seats in right.

It was Báez’s 24th home run this season and second with his new team — he has gone deep in both Mets wins since the trade. After rounding third on this one, he gestured in the direction of Miami’s dugout and had a few words to say.

“It was just some trash-talking basically from some fans behind the dugout,” Báez said. “They were disrespecting me. ... It was good-natured.”

The Mets, who pounded out 11 hits, added an insurance run in the eighth when Michael Conforto raced home on a passed ball by Alex Jackson. Conforto singled after Báez’s homer.

New York took advantage of some sloppy execution by the Marlins to score three runs after loading the bases with no outs in the second.

Dominic Smith doubled, Báez singled and Conforto walked before Jonathan Villar drove in a run with a groundout. Tomás Nido followed with a sharp grounder to Jesús Aguilar at first base, and he fired home in plenty of time to get Báez.

But the throw was slightly up the line, and El Mago pulled back his left hand and reached around Jackson’s tag with his right to touch the plate safely on a slick headfirst slide.

“For me, that’s a sure out,” Mets manager Luis Rojas said. “I don’t know how Báez was able to get to the plate at all. That was the most amazing part. It appeared (Jackson) would easily make that play.”

It was all instincts, Báez explained.

“I just reacted to the play in front of me,” he said. “I saw the way the ball was coming in and was able to get in there. I honestly didn’t plan (the slide) at all.”

Rojas said the effort just shows the type of pickup Báez will be for the Mets.

“This guy is a special player,” the manager said. “He brings that energy and hard work day in and day out.”

Mets starter Carlos Carrasco then reached on a fielder’s choice as pitcher Zach Thompson threw wildly to second, allowing Conforto to score an unearned run.

Miguel Castro (3-3) worked a hitless inning for the win. Trevor May earned his fourth save, after regular closer Edwin Díaz was placed on the paternity list earlier in the day.

Carrasco permitted two runs and five hits over 4 1/3 innings in his second start for New York. He struck out five.

Joe Panik chased Carrasco with a pinch-hit single in the fifth that plated Jorge Alfaro, who started the rally with a double. Miami cut its deficit to 3-2 when Jazz Chisholm Jr. beat out an attempted double play as Bryan De La Cruz scored.

Aguilar homered off Jeurys Familia in the sixth to tie it.

Thompson was effective apart from the second but lasted only four innings. He allowed three hits and walked two.

“That’s a good team across the field,” Marlins acting manager James Rowson said. “Every time you play a team like that, you know you’re going to be in a battle.”

MEETING TIME

Rojas said he called an impromptu team meeting before the game and was the only one who spoke.

“We met earlier and we talked a little bit as a family in there. ... I think we’re all on the same page with what we need to do,” he said. “It wasn’t a rah-rah meeting. ... It was just to get connected as a family would. It’s all good.”

New York is 9-11 since the All-Star break.

ROSTER MOVES

Mets: RHP Jake Reed was called up from Triple-A Syracuse. He was claimed off waivers from Tampa Bay on Monday. Rojas said Díaz will be out through at least Thursday.

TRAINER’S ROOM

Mets: RHP Stephen Nogosek (shoulder) and backup INF José Peraza (finger) are expected back within two weeks. C Bruce Maxwell (elbow) is out for the season.

Marlins: RHP Elieser Hernandez (right quad) will make a rehab start Thursday with Triple-A Jacksonville. Hernandez was injured June 4 in Pittsburgh. ... OF Jesus Sanchez, placed on the COVID-19 injured list in late July, continues to advance through the protocols with no definite timeframe for his return.

UP NEXT

LHP Rich Hill (6-4, 4.10 ERA) starts for the Mets in the series finale. The Marlins, who had penciled in Trevor Rogers before placing him on the family medical emergency list Tuesday, were undecided on their Thursday starter.

___

More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP_Sports